UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 20:56:31";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 00:26:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 00:26:31', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ab4dbdc1677
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-06 23:57:17', '069ab4dbdc1677', '1', '0.00', '0', '50', '1', '600.00', '550', '550', '0', '1', '2026-03-07 00:26:31', '', '1', '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','2026-03-06','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4842', '0', '2026-03-07 00:26:32', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '550', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-06 23:57:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 667;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00542', '4842', '24', '542', '1', '600', '600.00', '0', '', '0', '2026-03-07 00:26:32', '542', '0.00', '0', '1','0.00','','','0','0','0','0','0','0','0','0','','667-1,','1','1','0','0','600','600','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
        , lastbuyprice_withTax = 345, meanbuyprice_withTax = 345, lastbuyprice_withDiscountAndTax = 345
                where sellbilldetailid = 7358;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (542, '2026-03-07', 550, 345, 345
                    , 345, 345, 345, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 345, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+345
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 550, 345, 345
                    , 345, 345, 345, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0, 345, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+345
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2026-03-07 00:26:32' WHERE storedetailid = '542';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('542', '1', '1', '1', '4842', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '1', '2026-03-07 00:26:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2705258',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2704708','550', '0', '1', 'اضافة فاتورة مبيعات', '4842', '2705258', '2026-03-07 00:26:32', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '600', '600', '2026-03-07', '1', '0', '0', '2026-03-07 00:26:32','اضافة فاتورة مبيعات رقم 4842','1','0',null,'0','4842','sellbillController.php?do=showDetail&sellbillid=4842');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10809', '383', '550', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2704258', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10809', '398', '50', '','0');
UPDATE accountstree SET name = 'خصم مسموح به', customName = 'خصم مسموح به', customNameEn = '', nameEn = '', parent = '158', accountNature = '0', theValue = '52280', theOrder = '0', layingOrder = '51', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-08-08 17:58:26' WHERE id = '398';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10809', '143', '600', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2808135', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '345', '345', '2026-03-07', '1', '0', '0', '2026-03-07 00:26:32','اضافة فاتورة مبيعات رقم 4842 - صرف البضاعة من المخزن','1','0',null,'0','4842','sellbillController.php?do=showDetail&sellbillid=4842');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10810', '402', '345', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1995282.39', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10810', '382', '345', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1130676.89', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10809,0,10810' where sellbillid=4842;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 550, 345, 345
                    , 345, 345, 345, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,345, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+345
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 550, 345, 345
                    , 345, 345, 345, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,345, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+345
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 550, 345, 345
                    , 345, 345, 345, 345, 345, 345)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+550, netSellCostBuyPrice = netSellCostBuyPrice+345
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+345
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+345
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+345
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+345
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+345
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+345
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+345;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ab4dbdc1677 and sellbillId = 4842 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 20:56:33";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 00:26:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 00:26:33', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 21:00:43";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 00:30:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 00:30:43', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ab5499becdc
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 00:26:33', '069ab5499becdc', '1', '0.00', '0', '0', '1', '350.00', '350', '350', '0', '1', '2026-03-07 00:30:43', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','350','0','','0','0','350','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4843', '0', '2026-03-07 00:30:43', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '350', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 00:26:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 655;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00533', '4843', '15', '533', '1', '350', '350.00', '0', '', '0', '2026-03-07 00:30:43', '533', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','655-1,','1','1','0','0','350','350','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 = 7359;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (533, '2026-03-07', 350, 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+350, 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, '2026-03-07', 350, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2026-03-07 00:30:44' WHERE storedetailid = '533';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('533', '1', '1', '1', '4843', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '1', '2026-03-07 00:30:44','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2705608',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2705258','350', '0', '1', 'اضافة فاتورة مبيعات', '4843', '2705608', '2026-03-07 00:30:44', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '350', '350', '2026-03-07', '1', '0', '0', '2026-03-07 00:30:44','اضافة فاتورة مبيعات رقم 4843','1','0',null,'0','4843','sellbillController.php?do=showDetail&sellbillid=4843');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10811', '383', '350', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2704608', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10811', '143', '350', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2808485', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '240', '240', '2026-03-07', '1', '0', '0', '2026-03-07 00:30:44','اضافة فاتورة مبيعات رقم 4843 - صرف البضاعة من المخزن','1','0',null,'0','4843','sellbillController.php?do=showDetail&sellbillid=4843');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10812', '402', '240', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1995522.39', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10812', '382', '240', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1130916.89', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10811,0,10812' where sellbillid=4843;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 350, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, 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, '2026-03-07', 350, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, 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, 350, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+350, 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 069ab5499becdc and sellbillId = 4843 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 21:00:44";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 00:30:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 00:30:45', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 21:18:29";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 00:48:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 00:48:29', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ab5595a7fce
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 00:30:45', '069ab5595a7fce', '1', '0.00', '0', '50', '1', '1050.00', '1000', '1000', '0', '1', '2026-03-07 00:48:30', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','1000','0','','0','0','1000','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4844', '0', '2026-03-07 00:48:30', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1000', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 00:30:45','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('375','00420', '4844', '15', '420', '1', '550', '550.00', '0', '', '0', '2026-03-07 00:48:30', '420', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 374.25, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 374.25
        , lastbuyprice_withTax = 375, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 375
                where sellbilldetailid = 7360;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (420, '2026-03-07', 523.80952380952, 375, 375
                    , 374.25, 375, 374.25, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+523.80952380952, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+374.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+374.25
                            , 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, '2026-03-07', 523.80952380952, 375, 375
                    , 374.25, 375, 374.25, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+523.80952380952, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+374.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+374.25
                            , 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 = '-15', userid = '1', storedetaildate = '2026-03-07 00:48:30' WHERE storedetailid = '420';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('420', '1', '1', '1', '4844', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-14', '-15', '1', '2026-03-07 00:48:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 517;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00217', '4844', '1', '217', '1', '500', '500.00', '0', '', '0', '2026-03-07 00:48:30', '217', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','517-1,','1','1','0','0','500','500','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 = 7361;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (217, '2026-03-07', 476.19047619048, 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+476.19047619048, 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, '2026-03-07', 476.19047619048, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+476.19047619048, 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 = '12', userid = '1', storedetaildate = '2026-03-07 00:48:31' WHERE storedetailid = '217';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('217', '1', '1', '1', '4844', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '1', '2026-03-07 00:48:31','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2706608',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2705608','1000', '0', '1', 'اضافة فاتورة مبيعات', '4844', '2706608', '2026-03-07 00:48:31', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1050', '1050', '2026-03-07', '1', '0', '0', '2026-03-07 00:48:31','اضافة فاتورة مبيعات رقم 4844','1','0',null,'0','4844','sellbillController.php?do=showDetail&sellbillid=4844');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10813', '383', '1000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2705608', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10813', '398', '50', '','0');
UPDATE accountstree SET name = 'خصم مسموح به', customName = 'خصم مسموح به', customNameEn = '', nameEn = '', parent = '158', accountNature = '0', theValue = '52330', theOrder = '0', layingOrder = '51', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-08-08 17:58:26' WHERE id = '398';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10813', '143', '1050', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2809535', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '695', '695', '2026-03-07', '1', '0', '0', '2026-03-07 00:48:31','اضافة فاتورة مبيعات رقم 4844 - صرف البضاعة من المخزن','1','0',null,'0','4844','sellbillController.php?do=showDetail&sellbillid=4844');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10814', '402', '695', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1996217.39', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10814', '382', '695', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1131611.89', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10813,0,10814' where sellbillid=4844;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 1000, 695, 695
                    , 694.25, 695, 694.25, 695
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,695, 695, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1000, sellCostBuyPrice =sellCostBuyPrice+695
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+695, sellCostMeanBuyPrice = sellCostMeanBuyPrice+694.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+694.25
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+695
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+695
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+695
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 1000, 695, 695
                    , 694.25, 695, 694.25, 695
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,695, 695, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1000, sellCostBuyPrice =sellCostBuyPrice+695
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+695, sellCostMeanBuyPrice = sellCostMeanBuyPrice+694.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+694.25
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+695
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+695
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+695
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1000, 695, 695
                    , 694.25, 695, 694.25, 695, 695, 695)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1000, netSellCostBuyPrice = netSellCostBuyPrice+695
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+695
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+694.25
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+695
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+694.25
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+695
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+695
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+695;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ab5595a7fce and sellbillId = 4844 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 21:18:32";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 00:48:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 00:48:32', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 21:45:39";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 01:15:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 01:15:39', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ab59c1128f1
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 00:48:33', '069ab59c1128f1', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2026-03-07 01:15:40', '', '1', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4845', '0', '2026-03-07 01:15:40', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 00:48:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 665;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('322.54','00540', '4845', '13', '540', '1', '400', '400.00', '0', '', '0', '2026-03-07 01:15:40', '540', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','665-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 323.00 , meanbuyprice = 323.00, lastbuyprice_withDiscount = 322.54, meanbuyprice_withDiscount = 322.54
        , lastbuyprice_withTax = 323, meanbuyprice_withTax = 323, lastbuyprice_withDiscountAndTax = 322.54
                where sellbilldetailid = 7362;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (540, '2026-03-07', 400, 323, 323
                    , 323, 322.54, 322.54, 322.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 323, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+323
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+323, sellCostMeanBuyPrice = sellCostMeanBuyPrice+323
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+322.54, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+322.54
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+322.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+323
                            , 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, '2026-03-07', 400, 323, 323
                    , 323, 322.54, 322.54, 322.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 323, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+323
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+323, sellCostMeanBuyPrice = sellCostMeanBuyPrice+323
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+322.54, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+322.54
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+322.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+323
                            , 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 = '24', userid = '1', storedetaildate = '2026-03-07 01:15:40' WHERE storedetailid = '540';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('540', '1', '1', '1', '4845', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '1', '2026-03-07 01:15:40','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2707008',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2706608','400', '0', '1', 'اضافة فاتورة مبيعات', '4845', '2707008', '2026-03-07 01:15:41', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '400', '400', '2026-03-07', '1', '0', '0', '2026-03-07 01:15:41','اضافة فاتورة مبيعات رقم 4845','1','0',null,'0','4845','sellbillController.php?do=showDetail&sellbillid=4845');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10815', '383', '400', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2706008', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10815', '143', '400', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2809935', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '322.54', '322.54', '2026-03-07', '1', '0', '0', '2026-03-07 01:15:41','اضافة فاتورة مبيعات رقم 4845 - صرف البضاعة من المخزن','1','0',null,'0','4845','sellbillController.php?do=showDetail&sellbillid=4845');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10816', '402', '322.54', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1996539.93', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10816', '382', '322.54', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1131934.43', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10815,0,10816' where sellbillid=4845;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 400, 323, 323
                    , 323, 322.54, 322.54, 322.54
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,323, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+323
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+323, sellCostMeanBuyPrice = sellCostMeanBuyPrice+323
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+322.54, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+322.54
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+322.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+323
                            , 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, '2026-03-07', 400, 323, 323
                    , 323, 322.54, 322.54, 322.54
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,323, 323, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+323
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+323, sellCostMeanBuyPrice = sellCostMeanBuyPrice+323
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+322.54, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+322.54
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+322.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+323
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+323
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 400, 323, 323
                    , 323, 322.54, 322.54, 322.54, 323, 323)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+323
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+323
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+323
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+322.54
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+322.54
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+322.54
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+323
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+323;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ab59c1128f1 and sellbillId = 4845 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 21:45:41";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 01:15:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 01:15:42', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 22:20:52";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 01:50:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 01:50:52', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ab601eb9fcb
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 01:15:42', '069ab601eb9fcb', '1', '0.00', '0', '0', '1', '550.00', '550', '550', '0', '1', '2026-03-07 01:50:52', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','550','0','','0','0','550','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4846', '0', '2026-03-07 01:50:52', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '550', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 01:15:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 653;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00531', '4846', '24', '531', '1', '550', '550.00', '0', '', '0', '2026-03-07 01:50:52', '531', '0.00', '0', '1','0.00','','','0','0','0','0','0','0','0','0','','653-1,','1','1','0','0','550','550','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 = 7363;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (531, '2026-03-07', 550, 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+550, 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, '2026-03-07', 550, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, 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 = '4', userid = '1', storedetaildate = '2026-03-07 01:50:52' WHERE storedetailid = '531';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('531', '1', '1', '1', '4846', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '1', '2026-03-07 01:50:53','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2707558',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2707008','550', '0', '1', 'اضافة فاتورة مبيعات', '4846', '2707558', '2026-03-07 01:50:53', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '550', '550', '2026-03-07', '1', '0', '0', '2026-03-07 01:50:53','اضافة فاتورة مبيعات رقم 4846','1','0',null,'0','4846','sellbillController.php?do=showDetail&sellbillid=4846');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10817', '383', '550', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2706558', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10817', '143', '550', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2810485', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '310', '310', '2026-03-07', '1', '0', '0', '2026-03-07 01:50:53','اضافة فاتورة مبيعات رقم 4846 - صرف البضاعة من المخزن','1','0',null,'0','4846','sellbillController.php?do=showDetail&sellbillid=4846');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10818', '402', '310', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1996849.93', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10818', '382', '310', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1132244.43', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10817,0,10818' where sellbillid=4846;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 550, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 550, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 550, 310, 310
                    , 310, 310, 310, 310, 310, 310)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+550, netSellCostBuyPrice = netSellCostBuyPrice+310
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+310
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+310
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+310
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+310
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+310
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+310
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+310;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ab601eb9fcb and sellbillId = 4846 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 22:20:53";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 01:50:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 01:50:54', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 22:29:36";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 01:59:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 01:59:37', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ab685e73f76
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 01:50:54', '069ab685e73f76', '1', '0.00', '0', '0', '1', '500.00', '500', '500', '0', '1', '2026-03-07 01:59:37', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4847', '0', '2026-03-07 01:59:37', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 01:50:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 659;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00537', '4847', '6', '537', '1', '500', '500.00', '0', '', '0', '2026-03-07 01:59:38', '537', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','659-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 7364;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (537, '2026-03-07', 500, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 500, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2026-03-07 01:59:38' WHERE storedetailid = '537';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('537', '1', '1', '1', '4847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '1', '2026-03-07 01:59:38','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2708058',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2707558','500', '0', '1', 'اضافة فاتورة مبيعات', '4847', '2708058', '2026-03-07 01:59:38', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '500', '500', '2026-03-07', '1', '0', '0', '2026-03-07 01:59:38','اضافة فاتورة مبيعات رقم 4847','1','0',null,'0','4847','sellbillController.php?do=showDetail&sellbillid=4847');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10819', '383', '500', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2707058', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10819', '143', '500', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2810985', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '400', '400', '2026-03-07', '1', '0', '0', '2026-03-07 01:59:38','اضافة فاتورة مبيعات رقم 4847 - صرف البضاعة من المخزن','1','0',null,'0','4847','sellbillController.php?do=showDetail&sellbillid=4847');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10820', '402', '400', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1997249.93', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10820', '382', '400', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1132644.43', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10819,0,10820' where sellbillid=4847;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 500, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 500, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 500, 400, 400
                    , 400, 400, 400, 400, 400, 400)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, netSellCostBuyPrice = netSellCostBuyPrice+400
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+400
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+400
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+400
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+400
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+400
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+400
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+400;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ab685e73f76 and sellbillId = 4847 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 22:29:39";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 01:59:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 01:59:39', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:09:23";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:39:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 02:39:24', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ab6a6bd065e
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 01:59:39', '069ab6a6bd065e', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2026-03-07 02:39:24', '', '1', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4848', '0', '2026-03-07 02:39:24', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 01:59:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 638;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('239.96','00520', '4848', '15', '520', '1', '300', '300.00', '0', '', '0', '2026-03-07 02:39:24', '520', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','638-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 = 239.96, meanbuyprice_withDiscount = 239.96
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 239.96
                where sellbilldetailid = 7365;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (520, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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 = '80', userid = '1', storedetaildate = '2026-03-07 02:39:25' WHERE storedetailid = '520';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('520', '1', '1', '1', '4848', 'اضافة فاتورة مبيعات', 'sellbillController.php', '81', '80', '1', '2026-03-07 02:39:25','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2708358',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2708058','300', '0', '1', 'اضافة فاتورة مبيعات', '4848', '2708358', '2026-03-07 02:39:25', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '300', '300', '2026-03-07', '1', '0', '0', '2026-03-07 02:39:25','اضافة فاتورة مبيعات رقم 4848','1','0',null,'0','4848','sellbillController.php?do=showDetail&sellbillid=4848');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10821', '383', '300', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2707358', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10821', '143', '300', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2811285', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '239.96', '239.96', '2026-03-07', '1', '0', '0', '2026-03-07 02:39:25','اضافة فاتورة مبيعات رقم 4848 - صرف البضاعة من المخزن','1','0',null,'0','4848','sellbillController.php?do=showDetail&sellbillid=4848');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10822', '402', '239.96', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1997489.89', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10822', '382', '239.96', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1132884.39', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10821,0,10822' where sellbillid=4848;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, 239.96, 239.96, 239.96, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+240
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+240
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+239.96
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+239.96
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+239.96
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+240
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+240;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ab6a6bd065e and sellbillId = 4848 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:09:26";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:39:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 02:39:26', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:18:20";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:48:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2026-03-07 02:48:20', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:18:34";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:48:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2026-03-07 02:48:35', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:25:54";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:55:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 02:55:54', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:26:27";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:56:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 02:56:27', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ab779ad7550
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 02:55:54', '069ab779ad7550', '1', '0.00', '0', '0', '1', '600.00', '600', '600', '0', '1', '2026-03-07 02:56:27', '', '1', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','600','0','','0','0','600','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4849', '0', '2026-03-07 02:56:27', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '600', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 02:55:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 622;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('504.3','00430', '4849', '12', '430', '1', '600', '600.00', '0', '', '0', '2026-03-07 02:56:28', '430', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','622-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 505.00 , meanbuyprice = 505.00, lastbuyprice_withDiscount = 504.30, meanbuyprice_withDiscount = 504.63
        , lastbuyprice_withTax = 505, meanbuyprice_withTax = 505, lastbuyprice_withDiscountAndTax = 504.3
                where sellbilldetailid = 7366;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (430, '2026-03-07', 600, 505, 505
                    , 505, 504.3, 504.63, 504.83
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 505, 505, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+505
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+505, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+504.3, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+504.63
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+504.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+505
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+505
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 600, 505, 505
                    , 505, 504.3, 504.63, 504.83
                    , 0, 0, 0, 0
                    , 0, 0, 0, 505, 505, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+505
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+505, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+504.3, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+504.63
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+504.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+505
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+505
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2026-03-07 02:56:28' WHERE storedetailid = '430';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('430', '1', '1', '1', '4849', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '1', '2026-03-07 02:56:28','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2708958',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2708358','600', '0', '1', 'اضافة فاتورة مبيعات', '4849', '2708958', '2026-03-07 02:56:28', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '600', '600', '2026-03-07', '1', '0', '0', '2026-03-07 02:56:28','اضافة فاتورة مبيعات رقم 4849','1','0',null,'0','4849','sellbillController.php?do=showDetail&sellbillid=4849');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10823', '383', '600', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2707958', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10823', '143', '600', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2811885', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '504.3', '504.3', '2026-03-07', '1', '0', '0', '2026-03-07 02:56:28','اضافة فاتورة مبيعات رقم 4849 - صرف البضاعة من المخزن','1','0',null,'0','4849','sellbillController.php?do=showDetail&sellbillid=4849');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10824', '402', '504.3', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1997994.19', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10824', '382', '504.3', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1133388.69', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10823,0,10824' where sellbillid=4849;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 600, 505, 505
                    , 505, 504.3, 504.63, 504.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,505, 505, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+505
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+505, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+504.3, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+504.63
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+504.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+505
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+505
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 600, 505, 505
                    , 505, 504.3, 504.63, 504.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,505, 505, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+505
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+505, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+504.3, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+504.63
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+504.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+505
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+505
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 600, 505, 505
                    , 505, 504.3, 504.63, 504.83, 505, 505)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+600, netSellCostBuyPrice = netSellCostBuyPrice+505
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+505
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+505
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+504.3
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+504.63
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+504.83
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+505
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+505;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ab779ad7550 and sellbillId = 4849 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:26:29";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:56:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 02:56:29', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:28:55";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:58:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 02:58:55', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:29:03";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:59:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2026-03-07 02:59:04', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:29:19";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 02:59:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2026-03-07 02:59:19', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-06 23:49:27";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 03:19:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 03:19:27', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:36:03";
UPDATE programsettings SET companyname = 'Black Store', address = 'العمرانية الغربية - شارع التلاتينى - بجوار لهطة قشطة وامام مكتبة الشاملى / لايوجد مرتجع يوجد تبديل ف خلال 24 ساعه فقط ', specializtion = '', phone = '01014221501', faxnumber = '', email = 'mousa_maged@hotmail.com', website = '', logo = 'e3fcd25c1d55fcc1ccc78e924addfbeb.png', roundnumbers = '1', saveprinting = '1', deptprinting = '1', printingpapersize = '0', userid = '1', showPreviousPrice = '0', parcode = '0', priceing = '0', lastprice = '0', searchvalue = '2',clientsearchvalue = '2', updateproductprice = '0', allowfinsldelete = '0', updateclientprice = '0', `partition` = 'D', taxcard = '123456789123', commercialregistration = '1234', costcenter = '1', clinic = '1', workshop = '1', transport = '1', manufacturing = '1', masterCopy = '0' , dailyentrydate = '2020-04-18' ,updatefiledate = '2026-03-07',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='57a85883346811cbf7076a51c5bd887a2e96bf2df777a95668d34a3537aceedfe3f238b684c96d789642405e6f69293dbb311716d957a5ac40fe5570cf297eaf',allowdateedit = '0', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='0' , date='1' , limitamount = '0' , 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 = '0', 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='last_discount',Profitevaluation='last_discount' , delivery='0',premiums = '1',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 = ',0,0,0,',earlyrepayment = '0',visaPay = '0',headerPrint='38e56bc84e0c8adff190ee376e986bbd.png',headerPrintSand='',printSand='0',makeDailyEntry='1',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='0',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='0',incomeclient='1',showserial='1',editservice='1',showCurrency='0',qrerp='1',valueadded='0',qrcodesh='0',printfoot='',sellorder='0',numberprint='0',valueaddedbuy='0',simpleAddClientInBill='0',licenseNo='',maintenance='0',showPrevDiscount='0',vatvalueqr='0',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='0',quantitynew='0',showBillOperationSearch='0',obygyFolder='',clientsell='0',
                preorderperiod='0',useListPrice='0',ebillclient='0',importproduct='0',realestateunits='0',expensesupplier='0',changeOrderproduct='0',searchlimit='0',typebill='',roundnumbersbilltotal='0',noOfDecimalPlacesBillTotal='0',dailyEntryCostprice='last_discount',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='f76497e7f9954fee01a444e68fa09f1be4dd60fe65244bf68c850aee1f8d74beef4bee2f46ad28ffa177135b8699f786fe24d212710bbfcb90055fbf604d4f6e',
                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='1',webApiId='0',noBillEditTillPay='0' 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 < "2026-03-07 15:36:06";
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:36:42";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:06:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2026-03-07 19:06:43', '1', '', '::1', '', 'DESKTOP','https://localhost/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 < "2026-03-07 15:36:43";
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:36:48";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:06:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:06:48', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:37:45";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:07:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:07:45', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac5b2929768
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 19:06:49', '069ac5b2929768', '1', '0.00', '0', '0', '1', '1200.00', '1200', '1200', '0', '1', '2026-03-07 19:07:46', '', '1', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1200','0','','0','0','1200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4850', '0', '2026-03-07 19:07:46', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1200', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 19:06:49','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('430','00502', '4850', '1', '502', '1', '650', '650.00', '0', '', '0', '2026-03-07 19:07:46', '502', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','','1','1','0','0','650','650','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 = 7367;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (502, '2026-03-07', 650, 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+650, 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, '2026-03-07', 650, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 430, 430, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, 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 = '-1', userid = '1', storedetaildate = '2026-03-07 19:07:46' WHERE storedetailid = '502';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('502', '1', '1', '1', '4850', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '1', '2026-03-07 19:07:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 632;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00489', '4850', '15', '489', '1', '250', '250.00', '0', '', '0', '2026-03-07 19:07:47', '489', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','632-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 = 209.84
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where sellbilldetailid = 7368;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (489, '2026-03-07', 250, 210, 210
                    , 210, 210, 209.84, 209.87
                    , 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+209.84
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+209.87
                            , 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, '2026-03-07', 250, 210, 210
                    , 210, 210, 209.84, 209.87
                    , 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+209.84
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+209.87
                            , 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 = '62', userid = '1', storedetaildate = '2026-03-07 19:07:47' WHERE storedetailid = '489';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('489', '1', '1', '1', '4850', 'اضافة فاتورة مبيعات', 'sellbillController.php', '63', '62', '1', '2026-03-07 19:07:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 661;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00538', '4850', '24', '538', '1', '300', '300.00', '0', '', '0', '2026-03-07 19:07:47', '538', '0.00', '0', '1','0.00','','','0','0','0','0','0','0','0','0','','661-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 = 7369;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (538, '2026-03-07', 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, '2026-03-07', 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 = '25', userid = '1', storedetaildate = '2026-03-07 19:07:47' WHERE storedetailid = '538';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('538', '1', '1', '1', '4850', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '1', '2026-03-07 19:07:47','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2710158',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2708958','1200', '0', '1', 'اضافة فاتورة مبيعات', '4850', '2710158', '2026-03-07 19:07:47', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1200', '1200', '2026-03-07', '1', '0', '0', '2026-03-07 19:07:47','اضافة فاتورة مبيعات رقم 4850','1','0',null,'0','4850','sellbillController.php?do=showDetail&sellbillid=4850');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10825', '383', '1200', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2709158', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10825', '143', '1200', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2813085', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '890', '890', '2026-03-07', '1', '0', '0', '2026-03-07 19:07:47','اضافة فاتورة مبيعات رقم 4850 - صرف البضاعة من المخزن','1','0',null,'0','4850','sellbillController.php?do=showDetail&sellbillid=4850');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10826', '402', '890', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1998884.19', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10826', '382', '890', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1134278.69', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10825,0,10826' where sellbillid=4850;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 1200, 890, 890
                    , 890, 890, 889.84, 889.87
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,890, 890, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+889.84
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+889.87
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+890
                            , 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 (1, '2026-03-07', 1200, 890, 890
                    , 890, 890, 889.84, 889.87
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,890, 890, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+889.84
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+889.87
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+890
                            , 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, 1200, 890, 890
                    , 890, 890, 889.84, 889.87, 890, 890)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1200, netSellCostBuyPrice = netSellCostBuyPrice+890
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+890
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+890
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+890
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+889.84
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+889.87
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+890
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+890;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac5b2929768 and sellbillId = 4850 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:37:48";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:07:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:07:48', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:38:15";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:08:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:08:15', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac5b654172d
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 19:07:49', '069ac5b654172d', '1', '0.00', '0', '0', '1', '800.00', '800', '800', '0', '1', '2026-03-07 19:08:16', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','800','0','','0','0','800','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4851', '0', '2026-03-07 19:08:16', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 19:07:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 630;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('560','00383', '4851', '6', '383', '1', '650', '650.00', '0', '', '0', '2026-03-07 19:08:16', '383', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','630-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 560.00 , meanbuyprice = 419.78, lastbuyprice_withDiscount = 560.00, meanbuyprice_withDiscount = 419.78
        , lastbuyprice_withTax = 560, meanbuyprice_withTax = 283.55, lastbuyprice_withDiscountAndTax = 560
                where sellbilldetailid = 7370;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (383, '2026-03-07', 650, 560, 560
                    , 419.78, 560, 419.78, 554.15
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 560, 283.55, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+419.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+419.78
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+554.15
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+283.55
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 650, 560, 560
                    , 419.78, 560, 419.78, 554.15
                    , 0, 0, 0, 0
                    , 0, 0, 0, 560, 283.55, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+419.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+419.78
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+554.15
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+283.55
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 19:08:16' WHERE storedetailid = '383';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('383', '1', '1', '1', '4851', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-16', '-17', '1', '2026-03-07 19:08:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 589;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00492', '4851', '18', '492', '1', '150', '150.00', '0', '', '0', '2026-03-07 19:08:17', '492', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','589-1,','1','1','0','0','150','150','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
        , lastbuyprice_withTax = 75, meanbuyprice_withTax = 75, lastbuyprice_withDiscountAndTax = 75
                where sellbilldetailid = 7371;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (492, '2026-03-07', 150, 75, 75
                    , 75, 75, 75, 75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 75, 75, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+75
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+75, sellCostMeanBuyPrice = sellCostMeanBuyPrice+75
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+75, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+75
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+75
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+75
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 150, 75, 75
                    , 75, 75, 75, 75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 75, 75, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+75
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+75, sellCostMeanBuyPrice = sellCostMeanBuyPrice+75
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+75, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+75
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+75
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+75
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 19:08:17' WHERE storedetailid = '492';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('492', '1', '1', '1', '4851', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '1', '2026-03-07 19:08:17','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2710958',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2710158','800', '0', '1', 'اضافة فاتورة مبيعات', '4851', '2710958', '2026-03-07 19:08:17', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '800', '800', '2026-03-07', '1', '0', '0', '2026-03-07 19:08:17','اضافة فاتورة مبيعات رقم 4851','1','0',null,'0','4851','sellbillController.php?do=showDetail&sellbillid=4851');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10827', '383', '800', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2709958', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10827', '143', '800', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2813885', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '635', '635', '2026-03-07', '1', '0', '0', '2026-03-07 19:08:17','اضافة فاتورة مبيعات رقم 4851 - صرف البضاعة من المخزن','1','0',null,'0','4851','sellbillController.php?do=showDetail&sellbillid=4851');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10828', '402', '635', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '1999519.19', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10828', '382', '635', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1134913.69', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10827,0,10828' where sellbillid=4851;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 800, 635, 635
                    , 494.78, 635, 494.78, 629.15
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,635, 358.55, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+635
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+635, sellCostMeanBuyPrice = sellCostMeanBuyPrice+494.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+635, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+494.78
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+629.15
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+635
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+358.55
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 800, 635, 635
                    , 494.78, 635, 494.78, 629.15
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,635, 358.55, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+635
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+635, sellCostMeanBuyPrice = sellCostMeanBuyPrice+494.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+635, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+494.78
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+629.15
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+635
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+358.55
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 635, 635
                    , 494.78, 635, 494.78, 629.15, 635, 358.55)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+800, netSellCostBuyPrice = netSellCostBuyPrice+635
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+635
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+494.78
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+635
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+494.78
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+629.15
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+635
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+358.55;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac5b654172d and sellbillId = 4851 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:38:18";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:08:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:08:18', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:39:15";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:09:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2026-03-07 19:09:15', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:39:20";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:09:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2026-03-07 19:09:20', '1', 'show', '::1', '', 'DESKTOP','https://localhost/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:39:23";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:09:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:09:23', '1', 'showDetail', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=showDetail&sellbillid=4851');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:39:39";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:09:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:09:40', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:40:49";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:10:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:10:49', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac5bd487445
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 19:09:40', '069ac5bd487445', '1', '0.00', '0', '50', '1', '1950.00', '1900', '1900', '0', '1', '2026-03-07 19:10:50', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','1900','0','','0','0','1900','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4852', '0', '2026-03-07 19:10:50', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1900', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 19:09:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 549;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('700','00451', '4852', '6', '451', '1', '750', '750.00', '0', '', '0', '2026-03-07 19:10:50', '451', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','549-1,','1','1','0','0','750','750','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 700.00 , meanbuyprice = 685.00, lastbuyprice_withDiscount = 700.00, meanbuyprice_withDiscount = 685.00
        , lastbuyprice_withTax = 700, meanbuyprice_withTax = 670, lastbuyprice_withDiscountAndTax = 700
                where sellbilldetailid = 7372;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (451, '2026-03-07', 730.76923076923, 700, 700
                    , 685, 700, 685, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 700, 670, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+730.76923076923, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+685
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+685
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+670
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 730.76923076923, 700, 700
                    , 685, 700, 685, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 700, 670, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+730.76923076923, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+685
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+685
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+670
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 19:10:50' WHERE storedetailid = '451';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('451', '1', '1', '1', '4852', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '1', '2026-03-07 19:10:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 676;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('325','00408', '4852', '2', '408', '2', '450', '900.00', '0', '', '0', '2026-03-07 19:10:50', '408', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','676-2,','1','1','0','0','450','900','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 325.00 , meanbuyprice = 325.78, lastbuyprice_withDiscount = 325.00, meanbuyprice_withDiscount = 325.77
        , lastbuyprice_withTax = 325, meanbuyprice_withTax = 326.94, lastbuyprice_withDiscountAndTax = 325
                where sellbilldetailid = 7373;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (408, '2026-03-07', 876.92307692308, 650, 650
                    , 651.56, 650, 651.54, 653.4
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 650, 653.88, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+876.92307692308, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+651.56
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+651.54
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+653.4
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+653.88
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, '2026-03-07', 876.92307692308, 650, 650
                    , 651.56, 650, 651.54, 653.4
                    , 0, 0, 0, 0
                    , 0, 0, 0, 650, 653.88, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+876.92307692308, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+651.56
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+651.54
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+653.4
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+653.88
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 19:10:50' WHERE storedetailid = '408';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('408', '1', '2', '1', '4852', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '13', '1', '2026-03-07 19:10:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 638;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('239.96','00520', '4852', '15', '520', '1', '300', '300.00', '0', '', '0', '2026-03-07 19:10:50', '520', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','638-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 = 239.96, meanbuyprice_withDiscount = 239.96
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 239.96
                where sellbilldetailid = 7374;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (520, '2026-03-07', 292.30769230769, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+292.30769230769, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 292.30769230769, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+292.30769230769, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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 = '79', userid = '1', storedetaildate = '2026-03-07 19:10:50' WHERE storedetailid = '520';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('520', '1', '1', '1', '4852', 'اضافة فاتورة مبيعات', 'sellbillController.php', '80', '79', '1', '2026-03-07 19:10:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2712858',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2710958','1900', '0', '1', 'اضافة فاتورة مبيعات', '4852', '2712858', '2026-03-07 19:10:51', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1950', '1950', '2026-03-07', '1', '0', '0', '2026-03-07 19:10:51','اضافة فاتورة مبيعات رقم 4852','1','0',null,'0','4852','sellbillController.php?do=showDetail&sellbillid=4852');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10829', '383', '1900', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2711858', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10829', '398', '50', '','0');
UPDATE accountstree SET name = 'خصم مسموح به', customName = 'خصم مسموح به', customNameEn = '', nameEn = '', parent = '158', accountNature = '0', theValue = '52380', theOrder = '0', layingOrder = '51', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-08-08 17:58:26' WHERE id = '398';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10829', '143', '1950', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2815835', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1589.96', '1589.96', '2026-03-07', '1', '0', '0', '2026-03-07 19:10:51','اضافة فاتورة مبيعات رقم 4852 - صرف البضاعة من المخزن','1','0',null,'0','4852','sellbillController.php?do=showDetail&sellbillid=4852');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10830', '402', '1589.96', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2001109.15', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10830', '382', '1589.96', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1136503.65', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10829,0,10830' where sellbillid=4852;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 1900, 1590, 1590
                    , 1576.56, 1589.96, 1576.5, 1593.36
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1590, 1563.88, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1900, sellCostBuyPrice =sellCostBuyPrice+1590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1576.56
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1589.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1576.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1593.36
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1563.88
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 1900, 1590, 1590
                    , 1576.56, 1589.96, 1576.5, 1593.36
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1590, 1563.88, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1900, sellCostBuyPrice =sellCostBuyPrice+1590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1576.56
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1589.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1576.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1593.36
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1563.88
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1900, 1590, 1590
                    , 1576.56, 1589.96, 1576.5, 1593.36, 1590, 1563.88)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1900, netSellCostBuyPrice = netSellCostBuyPrice+1590
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1590
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1576.56
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1589.96
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1576.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1593.36
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1590
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1563.88;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac5bd487445 and sellbillId = 4852 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:40:52";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:10:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:10:52', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/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 < "2026-03-07 15:47:20";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:17:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2026-03-07 19:17:20', '1', '', '::1', '', 'DESKTOP','https://localhost/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 < "2026-03-07 15:47:21";
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:48:14";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:18:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 19:18:14', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:50:24";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:20:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:20:24', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac5c1ca728f
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 19:10:52', '069ac5c1ca728f', '1', '0.00', '0', '0', '1', '850.00', '850', '850', '0', '1', '2026-03-07 19:20:25', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','850','0','','0','0','850','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4853', '0', '2026-03-07 19:20:25', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '850', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 19:10: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 ('365','00256', '4853', '1', '256', '1', '550', '550.00', '0', '', '0', '2026-03-07 19:20:25', '256', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','','1','1','0','0','550','550','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 = 7375;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (256, '2026-03-07', 550, 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+550, 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, '2026-03-07', 550, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, 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 = '1', userid = '1', storedetaildate = '2026-03-07 19:20:25' WHERE storedetailid = '256';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('256', '1', '1', '1', '4853', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '1', '2026-03-07 19:20:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 638;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('239.96','00520', '4853', '15', '520', '1', '300', '300.00', '0', '', '0', '2026-03-07 19:20:25', '520', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','638-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 = 239.96, meanbuyprice_withDiscount = 239.96
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 239.96
                where sellbilldetailid = 7376;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (520, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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 = '78', userid = '1', storedetaildate = '2026-03-07 19:20:25' WHERE storedetailid = '520';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('520', '1', '1', '1', '4853', 'اضافة فاتورة مبيعات', 'sellbillController.php', '79', '78', '1', '2026-03-07 19:20:25','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2713708',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2712858','850', '0', '1', 'اضافة فاتورة مبيعات', '4853', '2713708', '2026-03-07 19:20:25', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '850', '850', '2026-03-07', '1', '0', '0', '2026-03-07 19:20:25','اضافة فاتورة مبيعات رقم 4853','1','0',null,'0','4853','sellbillController.php?do=showDetail&sellbillid=4853');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10831', '383', '850', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2712708', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10831', '143', '850', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2816685', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '604.96', '604.96', '2026-03-07', '1', '0', '0', '2026-03-07 19:20:25','اضافة فاتورة مبيعات رقم 4853 - صرف البضاعة من المخزن','1','0',null,'0','4853','sellbillController.php?do=showDetail&sellbillid=4853');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10832', '402', '604.96', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2001714.11', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10832', '382', '604.96', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1137108.61', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10831,0,10832' where sellbillid=4853;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 850, 605, 605
                    , 605, 604.96, 604.96, 604.96
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,605, 605, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+850, sellCostBuyPrice =sellCostBuyPrice+605
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+605, sellCostMeanBuyPrice = sellCostMeanBuyPrice+605
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+604.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+604.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+604.96
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+605
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+605
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 850, 605, 605
                    , 605, 604.96, 604.96, 604.96
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,605, 605, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+850, sellCostBuyPrice =sellCostBuyPrice+605
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+605, sellCostMeanBuyPrice = sellCostMeanBuyPrice+605
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+604.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+604.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+604.96
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+605
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+605
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 850, 605, 605
                    , 605, 604.96, 604.96, 604.96, 605, 605)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+850, netSellCostBuyPrice = netSellCostBuyPrice+605
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+605
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+605
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+604.96
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+604.96
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+604.96
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+605
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+605;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac5c1ca728f and sellbillId = 4853 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 15:50:26";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:20:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:20:26', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:04:42";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:34:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:34:43', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac5e5ae95d1
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 19:20:27', '069ac5e5ae95d1', '1', '0.00', '0', '20', '1', '300.00', '280', '280', '0', '1', '2026-03-07 19:34:43', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','280','0','','0','0','280','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4854', '0', '2026-03-07 19:34:43', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '280', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 19:20:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 636;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00496', '4854', '22', '496', '1', '300', '300.00', '0', '', '0', '2026-03-07 19:34:43', '496', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','636-1,','1','1','0','0','300','300','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 = 7377;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (496, '2026-03-07', 280, 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+280, 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, '2026-03-07', 280, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, 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 = '9', userid = '1', storedetaildate = '2026-03-07 19:34:44' WHERE storedetailid = '496';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('496', '1', '1', '1', '4854', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '1', '2026-03-07 19:34:44','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2713988',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2713708','280', '0', '1', 'اضافة فاتورة مبيعات', '4854', '2713988', '2026-03-07 19:34:44', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '300', '300', '2026-03-07', '1', '0', '0', '2026-03-07 19:34:44','اضافة فاتورة مبيعات رقم 4854','1','0',null,'0','4854','sellbillController.php?do=showDetail&sellbillid=4854');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10833', '383', '280', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2712988', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10833', '398', '20', '','0');
UPDATE accountstree SET name = 'خصم مسموح به', customName = 'خصم مسموح به', customNameEn = '', nameEn = '', parent = '158', accountNature = '0', theValue = '52400', theOrder = '0', layingOrder = '51', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-08-08 17:58:26' WHERE id = '398';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10833', '143', '300', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2816985', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '190', '190', '2026-03-07', '1', '0', '0', '2026-03-07 19:34:44','اضافة فاتورة مبيعات رقم 4854 - صرف البضاعة من المخزن','1','0',null,'0','4854','sellbillController.php?do=showDetail&sellbillid=4854');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10834', '402', '190', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2001904.11', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10834', '382', '190', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1137298.61', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10833,0,10834' where sellbillid=4854;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 280, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 280, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 280, 190, 190
                    , 190, 190, 190, 190, 190, 190)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+280, netSellCostBuyPrice = netSellCostBuyPrice+190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+190
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+190
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+190
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+190
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+190
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+190
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+190;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac5e5ae95d1 and sellbillId = 4854 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:04:45";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:34:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:34:45', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:18:03";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:48:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 19:48:03', '1', 'add', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=add');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,itemsymbol,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 ('محجر m4/شادو2800','','15','280','400', '400','400', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '280','280','280','280','280','0','42.86','0','0','.','0','0','0','280','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','280','280','0','0','0','0','0','0','0','0','0','0','0','0','-1','0','','280');
UPDATE product SET productName = 'محجر m4/شادو2800', productDescription = '', productCatId = '15', productBuyPrice = '280', productSellAllPrice = '400', productSellUnitPrice = '400', productSellHalfPrice = '400', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00556',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '280',lastbuyprice_withDiscount = '280',meanbuyprice = '280',meanbuyprice_withDiscount = '280' , productbuypricereal = '280' , buypricereal_precentage = '0' , buytotal_precentage = '42.86' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='280',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='280',meanbuyprice_withTax='280',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='280'  WHERE productId = '556';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '556', '1', '2026-03-07', '1', '0','0055601','400','400','400','280','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('556', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('556', '1', '0', '0', '556', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (556, 1,'2026-03-07 19:48:03',1)
                ON DUPLICATE KEY UPDATE productid = 556, edited = 1, sysdate = '2026-03-07 19:48:03', userid = 1;
UPDATE product SET productName = 'محجر m4/شادو2800', productDescription = '', productCatId = '15', productBuyPrice = '280.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00556',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '280',lastbuyprice_withDiscount = '280',meanbuyprice = '280',meanbuyprice_withDiscount = '280' , productbuypricereal = '280' , buypricereal_precentage = '0' , buytotal_precentage = '42.86' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='280',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='280',meanbuyprice_withTax='280',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='280'  WHERE productId = '556';
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,itemsymbol,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 ('حوض2559/لياقة/سيتي/كاندي2500','','15','250','350', '350','350', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '250','250','250','250','250','0','40','0','0','.','0','0','0','250','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','250','250','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','250');
UPDATE product SET productName = 'حوض2559/لياقة/سيتي/كاندي2500', productDescription = '', productCatId = '15', productBuyPrice = '250', productSellAllPrice = '350', productSellUnitPrice = '350', productSellHalfPrice = '350', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00557',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '250',lastbuyprice_withDiscount = '250',meanbuyprice = '250',meanbuyprice_withDiscount = '250' , productbuypricereal = '250' , buypricereal_precentage = '0' , buytotal_precentage = '40' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='250',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='250',meanbuyprice_withTax='250',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='250'  WHERE productId = '557';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '557', '1', '2026-03-07', '1', '0','0055701','350','350','350','250','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('557', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('557', '1', '0', '0', '557', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (557, 1,'2026-03-07 19:48:04',1)
                ON DUPLICATE KEY UPDATE productid = 557, edited = 1, sysdate = '2026-03-07 19:48:04', userid = 1;
UPDATE product SET productName = 'حوض2559/لياقة/سيتي/كاندي2500', productDescription = '', productCatId = '15', productBuyPrice = '250.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00557',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '250',lastbuyprice_withDiscount = '250',meanbuyprice = '250',meanbuyprice_withDiscount = '250' , productbuypricereal = '250' , buypricereal_precentage = '0' , buytotal_precentage = '40' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='250',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='250',meanbuyprice_withTax='250',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='250'  WHERE productId = '557';
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,itemsymbol,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 ('شادو 3300','','15','330','450', '450','450', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '330','330','330','330','330','0','36.36','0','0','.','0','0','0','330','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','330','330','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','330');
UPDATE product SET productName = 'شادو 3300', productDescription = '', productCatId = '15', productBuyPrice = '330', productSellAllPrice = '450', productSellUnitPrice = '450', productSellHalfPrice = '450', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00558',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '330',lastbuyprice_withDiscount = '330',meanbuyprice = '330',meanbuyprice_withDiscount = '330' , productbuypricereal = '330' , buypricereal_precentage = '0' , buytotal_precentage = '36.36' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='330',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='330'  WHERE productId = '558';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '558', '1', '2026-03-07', '1', '0','0055801','450','450','450','330','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('558', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('558', '1', '0', '0', '558', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (558, 1,'2026-03-07 19:48:05',1)
                ON DUPLICATE KEY UPDATE productid = 558, edited = 1, sysdate = '2026-03-07 19:48:05', userid = 1;
UPDATE product SET productName = 'شادو 3300', productDescription = '', productCatId = '15', productBuyPrice = '330.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00558',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '330',lastbuyprice_withDiscount = '330',meanbuyprice = '330',meanbuyprice_withDiscount = '330' , productbuypricereal = '330' , buypricereal_precentage = '0' , buytotal_precentage = '36.36' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='330',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='330'  WHERE productId = '558';
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,itemsymbol,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 ('راوندشادو 2900','','15','290','400', '400','400', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '290','290','290','290','290','0','37.93','0','0','.','0','0','0','290','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','290','290','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','290');
UPDATE product SET productName = 'راوندشادو 2900', productDescription = '', productCatId = '15', productBuyPrice = '290', productSellAllPrice = '400', productSellUnitPrice = '400', productSellHalfPrice = '400', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00559',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '290',lastbuyprice_withDiscount = '290',meanbuyprice = '290',meanbuyprice_withDiscount = '290' , productbuypricereal = '290' , buypricereal_precentage = '0' , buytotal_precentage = '37.93' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='290',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='290',meanbuyprice_withTax='290',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='290'  WHERE productId = '559';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '559', '1', '2026-03-07', '1', '0','0055901','400','400','400','290','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('559', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('559', '1', '0', '0', '559', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (559, 1,'2026-03-07 19:48:06',1)
                ON DUPLICATE KEY UPDATE productid = 559, edited = 1, sysdate = '2026-03-07 19:48:06', userid = 1;
UPDATE product SET productName = 'راوندشادو 2900', productDescription = '', productCatId = '15', productBuyPrice = '290.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00559',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '290',lastbuyprice_withDiscount = '290',meanbuyprice = '290',meanbuyprice_withDiscount = '290' , productbuypricereal = '290' , buypricereal_precentage = '0' , buytotal_precentage = '37.93' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='290',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='290',meanbuyprice_withTax='290',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='290'  WHERE productId = '559';
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,itemsymbol,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 ('مطبوع كاندي/محجر/فقيع/ستار/سيتي/تايسون/جزار','','15','260','350', '350','350', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '260','260','260','260','260','0','34.62','0','0','.','0','0','0','260','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','260','260','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','260');
UPDATE product SET productName = 'مطبوع كاندي/محجر/فقيع/ستار/سيتي/تايسون/جزار', productDescription = '', productCatId = '15', productBuyPrice = '260', productSellAllPrice = '350', productSellUnitPrice = '350', productSellHalfPrice = '350', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00560',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '34.62' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='260',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='260',meanbuyprice_withTax='260',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='260'  WHERE productId = '560';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '560', '1', '2026-03-07', '1', '0','0056001','350','350','350','260','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('560', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('560', '1', '0', '0', '560', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (560, 1,'2026-03-07 19:48:07',1)
                ON DUPLICATE KEY UPDATE productid = 560, edited = 1, sysdate = '2026-03-07 19:48:07', userid = 1;
UPDATE product SET productName = 'مطبوع كاندي/محجر/فقيع/ستار/سيتي/تايسون/جزار', productDescription = '', productCatId = '15', productBuyPrice = '260.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00560',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '34.62' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='260',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='260',meanbuyprice_withTax='260',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='260'  WHERE productId = '560';
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,itemsymbol,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 ('سيتي/m4/تاتش','','15','200','300', '300','300', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '200','200','200','200','200','0','50','0','0','.','0','0','0','200','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','200','200','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','200');
UPDATE product SET productName = 'سيتي/m4/تاتش', productDescription = '', productCatId = '15', productBuyPrice = '200', productSellAllPrice = '300', productSellUnitPrice = '300', productSellHalfPrice = '300', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00561',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200',lastbuyprice_withDiscount = '200',meanbuyprice = '200',meanbuyprice_withDiscount = '200' , productbuypricereal = '200' , buypricereal_precentage = '0' , buytotal_precentage = '50' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='200',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='200',meanbuyprice_withTax='200',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='200'  WHERE productId = '561';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '561', '1', '2026-03-07', '1', '0','0056101','300','300','300','200','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('561', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '1', '0', '0', '561', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (561, 1,'2026-03-07 19:48:08',1)
                ON DUPLICATE KEY UPDATE productid = 561, edited = 1, sysdate = '2026-03-07 19:48:08', userid = 1;
UPDATE product SET productName = 'سيتي/m4/تاتش', productDescription = '', productCatId = '15', productBuyPrice = '200.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00561',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200',lastbuyprice_withDiscount = '200',meanbuyprice = '200',meanbuyprice_withDiscount = '200' , productbuypricereal = '200' , buypricereal_precentage = '0' , buytotal_precentage = '50' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='200',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='200',meanbuyprice_withTax='200',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='200'  WHERE productId = '561';
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,itemsymbol,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 ('حوض مستورد2558','','15','220','300', '300','300', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '220','220','220','220','220','0','36.36','0','0','.','0','0','0','220','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','220','220','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','220');
UPDATE product SET productName = 'حوض مستورد2558', productDescription = '', productCatId = '15', productBuyPrice = '220', productSellAllPrice = '300', productSellUnitPrice = '300', productSellHalfPrice = '300', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00562',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220',lastbuyprice_withDiscount = '220',meanbuyprice = '220',meanbuyprice_withDiscount = '220' , productbuypricereal = '220' , buypricereal_precentage = '0' , buytotal_precentage = '36.36' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='220',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='220',meanbuyprice_withTax='220',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='220'  WHERE productId = '562';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '562', '1', '2026-03-07', '1', '0','0056201','300','300','300','220','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('562', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('562', '1', '0', '0', '562', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (562, 1,'2026-03-07 19:48:09',1)
                ON DUPLICATE KEY UPDATE productid = 562, edited = 1, sysdate = '2026-03-07 19:48:09', userid = 1;
UPDATE product SET productName = 'حوض مستورد2558', productDescription = '', productCatId = '15', productBuyPrice = '220.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00562',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220',lastbuyprice_withDiscount = '220',meanbuyprice = '220',meanbuyprice_withDiscount = '220' , productbuypricereal = '220' , buypricereal_precentage = '0' , buytotal_precentage = '36.36' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='220',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='220',meanbuyprice_withTax='220',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='220'  WHERE productId = '562';
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,itemsymbol,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 ('ميلتون زونط الجزار','','15','270','350', '350','350', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '270','270','270','270','270','0','29.63','0','0','.','0','0','0','270','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','270','270','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','270');
UPDATE product SET productName = 'ميلتون زونط الجزار', productDescription = '', productCatId = '15', productBuyPrice = '270', productSellAllPrice = '350', productSellUnitPrice = '350', productSellHalfPrice = '350', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00563',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270' , buypricereal_precentage = '0' , buytotal_precentage = '29.63' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='270',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='270',meanbuyprice_withTax='270',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='270'  WHERE productId = '563';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '563', '1', '2026-03-07', '1', '0','0056301','350','350','350','270','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('563', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('563', '1', '0', '0', '563', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (563, 1,'2026-03-07 19:48:10',1)
                ON DUPLICATE KEY UPDATE productid = 563, edited = 1, sysdate = '2026-03-07 19:48:10', userid = 1;
UPDATE product SET productName = 'ميلتون زونط الجزار', productDescription = '', productCatId = '15', productBuyPrice = '270.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00563',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270' , buypricereal_precentage = '0' , buytotal_precentage = '29.63' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='270',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='270',meanbuyprice_withTax='270',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='270'  WHERE productId = '563';
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,itemsymbol,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 ('بوكس فيت كاندي2100','','15','210','250', '250','250', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '210','210','210','210','210','0','19.05','0','0','.','0','0','0','210','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','210','210','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','210');
UPDATE product SET productName = 'بوكس فيت كاندي2100', productDescription = '', productCatId = '15', productBuyPrice = '210', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00564',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210',lastbuyprice_withDiscount = '210',meanbuyprice = '210',meanbuyprice_withDiscount = '210' , productbuypricereal = '210' , buypricereal_precentage = '0' , buytotal_precentage = '19.05' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='210',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='210'  WHERE productId = '564';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '564', '1', '2026-03-07', '1', '0','0056401','250','250','250','210','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('564', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('564', '1', '0', '0', '564', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (564, 1,'2026-03-07 19:48:11',1)
                ON DUPLICATE KEY UPDATE productid = 564, edited = 1, sysdate = '2026-03-07 19:48:11', userid = 1;
UPDATE product SET productName = 'بوكس فيت كاندي2100', productDescription = '', productCatId = '15', productBuyPrice = '210.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '250.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00564',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210',lastbuyprice_withDiscount = '210',meanbuyprice = '210',meanbuyprice_withDiscount = '210' , productbuypricereal = '210' , buypricereal_precentage = '0' , buytotal_precentage = '19.05' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='210',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='210'  WHERE productId = '564';
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,itemsymbol,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 ('تايسون قطن زنط2350','','15','235','300', '300','300', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '235','235','235','235','235','0','27.66','0','0','.','0','0','0','235','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','235','235','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','235');
UPDATE product SET productName = 'تايسون قطن زنط2350', productDescription = '', productCatId = '15', productBuyPrice = '235', productSellAllPrice = '300', productSellUnitPrice = '300', productSellHalfPrice = '300', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00565',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '235',lastbuyprice_withDiscount = '235',meanbuyprice = '235',meanbuyprice_withDiscount = '235' , productbuypricereal = '235' , buypricereal_precentage = '0' , buytotal_precentage = '27.66' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='235',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='235'  WHERE productId = '565';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '565', '1', '2026-03-07', '1', '0','0056501','300','300','300','235','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('565', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('565', '1', '0', '0', '565', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (565, 1,'2026-03-07 19:48:12',1)
                ON DUPLICATE KEY UPDATE productid = 565, edited = 1, sysdate = '2026-03-07 19:48:12', userid = 1;
UPDATE product SET productName = 'تايسون قطن زنط2350', productDescription = '', productCatId = '15', productBuyPrice = '235.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00565',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '235',lastbuyprice_withDiscount = '235',meanbuyprice = '235',meanbuyprice_withDiscount = '235' , productbuypricereal = '235' , buypricereal_precentage = '0' , buytotal_precentage = '27.66' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='235',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='235'  WHERE productId = '565';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:18:14";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:48:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 19:48:14', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:22:03";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:52:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 19:52:03', '1', 'add', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=add');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,itemsymbol,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 ('افندينا 1102','','24','540','750', '750','750', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '540','540','540','540','540','0','38.89','0','0','.','0','0','0','540','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','540','540','0','0','0','0','0','0','0','0','0','0','0','0','-1','0','','540');
UPDATE product SET productName = 'افندينا 1102', productDescription = '', productCatId = '24', productBuyPrice = '540', productSellAllPrice = '750', productSellUnitPrice = '750', productSellHalfPrice = '750', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00566',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '540',lastbuyprice_withDiscount = '540',meanbuyprice = '540',meanbuyprice_withDiscount = '540' , productbuypricereal = '540' , buypricereal_precentage = '0' , buytotal_precentage = '38.89' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='540',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='540',meanbuyprice_withTax='540',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='540'  WHERE productId = '566';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '566', '1', '2026-03-07', '1', '0','0056601','750','750','750','540','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('566', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('566', '1', '0', '0', '566', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (566, 1,'2026-03-07 19:52:04',1)
                ON DUPLICATE KEY UPDATE productid = 566, edited = 1, sysdate = '2026-03-07 19:52:04', userid = 1;
UPDATE product SET productName = 'افندينا 1102', productDescription = '', productCatId = '24', productBuyPrice = '540.00', productSellAllPrice = '750.00', productSellUnitPrice = '750.00', productSellHalfPrice = '750.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00566',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '540',lastbuyprice_withDiscount = '540',meanbuyprice = '540',meanbuyprice_withDiscount = '540' , productbuypricereal = '540' , buypricereal_precentage = '0' , buytotal_precentage = '38.89' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='540',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='540',meanbuyprice_withTax='540',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='540'  WHERE productId = '566';
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,itemsymbol,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 ('شروال شرايح روبن','','24','450','600', '600','600', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '450','450','450','450','450','0','33.33','0','0','.','0','0','0','450','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','450','450','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','450');
UPDATE product SET productName = 'شروال شرايح روبن', productDescription = '', productCatId = '24', productBuyPrice = '450', productSellAllPrice = '600', productSellUnitPrice = '600', productSellHalfPrice = '600', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00567',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '33.33' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '567';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '567', '1', '2026-03-07', '1', '0','0056701','600','600','600','450','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('567', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('567', '1', '0', '0', '567', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (567, 1,'2026-03-07 19:52:05',1)
                ON DUPLICATE KEY UPDATE productid = 567, edited = 1, sysdate = '2026-03-07 19:52:05', userid = 1;
UPDATE product SET productName = 'شروال شرايح روبن', productDescription = '', productCatId = '24', productBuyPrice = '450.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00567',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '33.33' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '567';
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,itemsymbol,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 ('شروال جينز5024','','24','450','600', '600','600', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '450','450','450','450','450','0','33.33','0','0','.','0','0','0','450','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','450','450','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','450');
UPDATE product SET productName = 'شروال جينز5024', productDescription = '', productCatId = '24', productBuyPrice = '450', productSellAllPrice = '600', productSellUnitPrice = '600', productSellHalfPrice = '600', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00568',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '33.33' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '568';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '568', '1', '2026-03-07', '1', '0','0056801','600','600','600','450','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('568', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('568', '1', '0', '0', '568', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (568, 1,'2026-03-07 19:52:06',1)
                ON DUPLICATE KEY UPDATE productid = 568, edited = 1, sysdate = '2026-03-07 19:52:06', userid = 1;
UPDATE product SET productName = 'شروال جينز5024', productDescription = '', productCatId = '24', productBuyPrice = '450.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00568',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '33.33' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '568';
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,itemsymbol,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 ('الو لورد','','24','475','650', '650','650', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '475','475','475','475','475','0','36.84','0','0','.','0','0','0','475','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','475','475','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','475');
UPDATE product SET productName = 'الو لورد', productDescription = '', productCatId = '24', productBuyPrice = '475', productSellAllPrice = '650', productSellUnitPrice = '650', productSellHalfPrice = '650', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00569',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '475',lastbuyprice_withDiscount = '475',meanbuyprice = '475',meanbuyprice_withDiscount = '475' , productbuypricereal = '475' , buypricereal_precentage = '0' , buytotal_precentage = '36.84' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='475',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='475',meanbuyprice_withTax='475',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='475'  WHERE productId = '569';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '569', '1', '2026-03-07', '1', '0','0056901','650','650','650','475','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('569', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('569', '1', '0', '0', '569', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (569, 1,'2026-03-07 19:52:07',1)
                ON DUPLICATE KEY UPDATE productid = 569, edited = 1, sysdate = '2026-03-07 19:52:07', userid = 1;
UPDATE product SET productName = 'الو لورد', productDescription = '', productCatId = '24', productBuyPrice = '475.00', productSellAllPrice = '650.00', productSellUnitPrice = '650.00', productSellHalfPrice = '650.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00569',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '475',lastbuyprice_withDiscount = '475',meanbuyprice = '475',meanbuyprice_withDiscount = '475' , productbuypricereal = '475' , buypricereal_precentage = '0' , buytotal_precentage = '36.84' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='475',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='475',meanbuyprice_withTax='475',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='475'  WHERE productId = '569';
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,itemsymbol,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 ('شروال جينز5022','','24','450','600', '600','600', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '450','450','450','450','450','0','33.33','0','0','.','0','0','0','450','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','450','450','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','450');
UPDATE product SET productName = 'شروال جينز5022', productDescription = '', productCatId = '24', productBuyPrice = '450', productSellAllPrice = '600', productSellUnitPrice = '600', productSellHalfPrice = '600', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00570',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '33.33' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '570';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '570', '1', '2026-03-07', '1', '0','0057001','600','600','600','450','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('570', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('570', '1', '0', '0', '570', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (570, 1,'2026-03-07 19:52:08',1)
                ON DUPLICATE KEY UPDATE productid = 570, edited = 1, sysdate = '2026-03-07 19:52:08', userid = 1;
UPDATE product SET productName = 'شروال جينز5022', productDescription = '', productCatId = '24', productBuyPrice = '450.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00570',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '33.33' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '570';
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,itemsymbol,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 ('افندينا1111','','24','560','700', '700','700', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '560','560','560','560','560','0','25','0','0','.','0','0','0','560','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','560','560','0','0','0','0','0','0','0','1','0','0','0','0','0','0','','560');
UPDATE product SET productName = 'افندينا1111', productDescription = '', productCatId = '24', productBuyPrice = '560', productSellAllPrice = '700', productSellUnitPrice = '700', productSellHalfPrice = '700', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00571',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '560',lastbuyprice_withDiscount = '560',meanbuyprice = '560',meanbuyprice_withDiscount = '560' , productbuypricereal = '560' , buypricereal_precentage = '0' , buytotal_precentage = '25' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='560',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='560',meanbuyprice_withTax='560',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='560'  WHERE productId = '571';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '571', '1', '2026-03-07', '1', '0','0057101','700','700','700','560','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('571', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('571', '1', '0', '0', '571', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (571, 1,'2026-03-07 19:52:09',1)
                ON DUPLICATE KEY UPDATE productid = 571, edited = 1, sysdate = '2026-03-07 19:52:09', userid = 1;
UPDATE product SET productName = 'افندينا1111', productDescription = '', productCatId = '24', productBuyPrice = '560.00', productSellAllPrice = '700.00', productSellUnitPrice = '700.00', productSellHalfPrice = '700.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00571',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '560',lastbuyprice_withDiscount = '560',meanbuyprice = '560',meanbuyprice_withDiscount = '560' , productbuypricereal = '560' , buypricereal_precentage = '0' , buytotal_precentage = '25' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='560',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='560',meanbuyprice_withTax='560',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='560'  WHERE productId = '571';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:22:10";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:52:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 19:52:11', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:22:50";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:52:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 19:52:50', '1', 'show', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:22:55";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:52:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 19:52:55', '1', 'show', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:23:03";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:53:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:53:03', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:23:14";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:53:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 19:53:15', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:24:02";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:54:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 19:54:02', '1', 'add', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=add');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,itemsymbol,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 ('جاكت افريكانو/دودج','','12','400','450', '450','450', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '400','400','400','400','400','0','12.5','0','0','.','0','0','0','400','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','400','400','0','0','0','0','0','0','0','0','0','0','0','0','-1','0','','400');
UPDATE product SET productName = 'جاكت افريكانو/دودج', productDescription = '', productCatId = '12', productBuyPrice = '400', productSellAllPrice = '450', productSellUnitPrice = '450', productSellHalfPrice = '450', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00572',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '400',lastbuyprice_withDiscount = '400',meanbuyprice = '400',meanbuyprice_withDiscount = '400' , productbuypricereal = '400' , buypricereal_precentage = '0' , buytotal_precentage = '12.5' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='400',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',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='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='400'  WHERE productId = '572';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '572', '1', '2026-03-07', '1', '0','0057201','450','450','450','400','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('572', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('572', '1', '0', '0', '572', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (572, 1,'2026-03-07 19:54:03',1)
                ON DUPLICATE KEY UPDATE productid = 572, edited = 1, sysdate = '2026-03-07 19:54:03', userid = 1;
UPDATE product SET productName = 'جاكت افريكانو/دودج', productDescription = '', productCatId = '12', productBuyPrice = '400.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00572',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '400',lastbuyprice_withDiscount = '400',meanbuyprice = '400',meanbuyprice_withDiscount = '400' , productbuypricereal = '400' , buypricereal_precentage = '0' , buytotal_precentage = '12.5' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='400',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',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='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='400'  WHERE productId = '572';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:24:05";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:54:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 19:54:05', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:24:10";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 19:54:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2026-03-07 19:54:10', '1', 'bill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:33:54";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:03:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:03:55', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:33:58";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:03:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2026-03-07 20:03:58', '1', '', '::1', '', 'DESKTOP','https://localhost/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 < "2026-03-07 16:33:59";
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:34:00";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:04:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:04:01', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:34:03";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:04:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2026-03-07 20:04:03', '1', '', '::1', '', 'DESKTOP','https://localhost/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 < "2026-03-07 16:34:04";
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:34:05";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:04:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:04:06', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:34:08";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:04:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2026-03-07 20:04:08', '1', '', '::1', '', 'DESKTOP','https://localhost/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 < "2026-03-07 16:34:09";
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:34:11";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:04:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:04:11', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:35:49";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:05:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:05:49', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac688ba73d7
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 20:03:55', '069ac688ba73d7', '1', '0.00', '0', '0', '1', '500.00', '500', '500', '0', '1', '2026-03-07 20:05:50', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4855', '0', '2026-03-07 20:05:50', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 20:03:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 625;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('349.52','00513', '4855', '6', '513', '1', '500', '500.00', '0', '', '0', '2026-03-07 20:05:50', '513', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','625-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 349.52, meanbuyprice_withDiscount = 349.52
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 349.52
                where sellbilldetailid = 7378;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (513, '2026-03-07', 500, 350, 350
                    , 350, 349.52, 349.52, 349.52
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+349.52, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+349.52
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+349.52
                            , 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, '2026-03-07', 500, 350, 350
                    , 350, 349.52, 349.52, 349.52
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+349.52, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+349.52
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+349.52
                            , 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 = '2', userid = '1', storedetaildate = '2026-03-07 20:05:50' WHERE storedetailid = '513';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('513', '1', '1', '1', '4855', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '1', '2026-03-07 20:05:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2714488',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2713988','500', '0', '1', 'اضافة فاتورة مبيعات', '4855', '2714488', '2026-03-07 20:05:50', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '500', '500', '2026-03-07', '1', '0', '0', '2026-03-07 20:05:50','اضافة فاتورة مبيعات رقم 4855','1','0',null,'0','4855','sellbillController.php?do=showDetail&sellbillid=4855');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10835', '383', '500', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2713488', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10835', '143', '500', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2817485', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '349.52', '349.52', '2026-03-07', '1', '0', '0', '2026-03-07 20:05:50','اضافة فاتورة مبيعات رقم 4855 - صرف البضاعة من المخزن','1','0',null,'0','4855','sellbillController.php?do=showDetail&sellbillid=4855');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10836', '402', '349.52', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2002253.63', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10836', '382', '349.52', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1137648.13', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10835,0,10836' where sellbillid=4855;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 500, 350, 350
                    , 350, 349.52, 349.52, 349.52
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+349.52, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+349.52
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+349.52
                            , 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, '2026-03-07', 500, 350, 350
                    , 350, 349.52, 349.52, 349.52
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+349.52, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+349.52
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+349.52
                            , 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, 500, 350, 350
                    , 350, 349.52, 349.52, 349.52, 350, 350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+349.52
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+349.52
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+349.52
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+350
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+350;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac688ba73d7 and sellbillId = 4855 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:35:51";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:05:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:05:51', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:49:54";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:19:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:19:55', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:52:30";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:22:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:22:30', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac68919cb95
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 20:04:01', '069ac68919cb95', '1', '0.00', '0', '0', '1', '650.00', '650', '650', '0', '1', '2026-03-07 20:22:31', '', '1', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','650','0','','0','0','650','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4856', '0', '2026-03-07 20:22:31', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '650', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 20:04:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 630;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('560','00383', '4856', '6', '383', '1', '650', '650.00', '0', '', '0', '2026-03-07 20:22:31', '383', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','630-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 560.00 , meanbuyprice = 419.78, lastbuyprice_withDiscount = 560.00, meanbuyprice_withDiscount = 419.78
        , lastbuyprice_withTax = 560, meanbuyprice_withTax = 283.55, lastbuyprice_withDiscountAndTax = 560
                where sellbilldetailid = 7379;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (383, '2026-03-07', 650, 560, 560
                    , 419.78, 560, 419.78, 554.15
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 560, 283.55, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+419.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+419.78
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+554.15
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+283.55
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 650, 560, 560
                    , 419.78, 560, 419.78, 554.15
                    , 0, 0, 0, 0
                    , 0, 0, 0, 560, 283.55, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+419.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+419.78
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+554.15
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+283.55
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 20:22:31' WHERE storedetailid = '383';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('383', '1', '1', '1', '4856', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-17', '-18', '1', '2026-03-07 20:22:31','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2715138',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2714488','650', '0', '1', 'اضافة فاتورة مبيعات', '4856', '2715138', '2026-03-07 20:22:31', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '650', '650', '2026-03-07', '1', '0', '0', '2026-03-07 20:22:31','اضافة فاتورة مبيعات رقم 4856','1','0',null,'0','4856','sellbillController.php?do=showDetail&sellbillid=4856');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10837', '383', '650', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2714138', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10837', '143', '650', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2818135', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '560', '560', '2026-03-07', '1', '0', '0', '2026-03-07 20:22:31','اضافة فاتورة مبيعات رقم 4856 - صرف البضاعة من المخزن','1','0',null,'0','4856','sellbillController.php?do=showDetail&sellbillid=4856');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10838', '402', '560', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2002813.63', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10838', '382', '560', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1138208.13', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10837,0,10838' where sellbillid=4856;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 650, 560, 560
                    , 419.78, 560, 419.78, 554.15
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,560, 283.55, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+419.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+419.78
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+554.15
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+283.55
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 650, 560, 560
                    , 419.78, 560, 419.78, 554.15
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,560, 283.55, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+419.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+560, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+419.78
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+554.15
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+283.55
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 650, 560, 560
                    , 419.78, 560, 419.78, 554.15, 560, 283.55)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+650, netSellCostBuyPrice = netSellCostBuyPrice+560
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+560
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+419.78
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+560
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+419.78
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+554.15
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+560
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+283.55;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac68919cb95 and sellbillId = 4856 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:52:32";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:22:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:22:32', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:53:02";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:23:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:23:02', '1', 'add', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=add');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,itemsymbol,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 ('شروال محجرتقطيع جديد','','2','315','500', '500','500', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '315','315','315','315','315','0','58.73','0','0','.','0','0','0','315','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','315','315','0','0','0','0','0','0','0','0','0','0','0','0','-1','0','','315');
UPDATE product SET productName = 'شروال محجرتقطيع جديد', productDescription = '', productCatId = '2', productBuyPrice = '315', productSellAllPrice = '500', productSellUnitPrice = '500', productSellHalfPrice = '500', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00573',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '315',lastbuyprice_withDiscount = '315',meanbuyprice = '315',meanbuyprice_withDiscount = '315' , productbuypricereal = '315' , buypricereal_precentage = '0' , buytotal_precentage = '58.73' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='315',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='315',meanbuyprice_withTax='315',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='315'  WHERE productId = '573';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '573', '1', '2026-03-07', '1', '0','0057301','500','500','500','315','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('573', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('573', '1', '0', '0', '573', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (573, 1,'2026-03-07 20:23:03',1)
                ON DUPLICATE KEY UPDATE productid = 573, edited = 1, sysdate = '2026-03-07 20:23:03', userid = 1;
UPDATE product SET productName = 'شروال محجرتقطيع جديد', productDescription = '', productCatId = '2', productBuyPrice = '315.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00573',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '315',lastbuyprice_withDiscount = '315',meanbuyprice = '315',meanbuyprice_withDiscount = '315' , productbuypricereal = '315' , buypricereal_precentage = '0' , buytotal_precentage = '58.73' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='315',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='315',meanbuyprice_withTax='315',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='315'  WHERE productId = '573';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:53:05";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:23:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:23:05', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:55:21";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:25:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:25:21', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:56:11";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:26:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:26:12', '1', 'add', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=add');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,itemsymbol,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 ('شروال سوبر باجي روبن','','24','450','650', '650','650', '2026-03-07', '0', '1', '0', '', '0', '0', '0', '0', '0', '450','450','450','450','450','0','44.44','0','0','.','0','0','0','450','0','','','0','0','0','','0','0','0','GS1','','','','0','0','0','0','','0','0','','0','','450','450','0','0','0','0','0','0','0','0','0','0','0','0','-1','0','','450');
UPDATE product SET productName = 'شروال سوبر باجي روبن', productDescription = '', productCatId = '24', productBuyPrice = '450', productSellAllPrice = '650', productSellUnitPrice = '650', productSellHalfPrice = '650', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00574',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '44.44' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '574';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '574', '1', '2026-03-07', '1', '0','0057401','650','650','650','450','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('574', '1', '0', '1', '2026-03-07');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('574', '1', '0', '0', '574', 'إضافة منتج', 'productController.php', '0', '0', '1', '2026-03-07','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (574, 1,'2026-03-07 20:26:12',1)
                ON DUPLICATE KEY UPDATE productid = 574, edited = 1, sysdate = '2026-03-07 20:26:12', userid = 1;
UPDATE product SET productName = 'شروال سوبر باجي روبن', productDescription = '', productCatId = '24', productBuyPrice = '450.00', productSellAllPrice = '650.00', productSellUnitPrice = '650.00', productSellHalfPrice = '650.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00574',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '44.44' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',webApiId='0',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '574';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:56:14";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:26:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:26:14', '1', '', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:59:01";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:29:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2026-03-07 20:29:01', '1', 'add', '::1', '', 'DESKTOP','https://localhost/erp/controllers/buyBillController.php?do=add&return_url=1&billnameid=1');
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 ('069ac6642e035f', '2026-03-07 19:54:10', '1', '1566682.00', '1681182', '0', '0', '114500.00',  '114500.00', '', '114500', '1', '2026-03-07 20:29:02', '', '1', '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 ('00556', '118', '15', '556', '19', '280', '5320.00', '0', '', '2026-03-07 20:29:02', '556','','','0','0','0','0','0',null,'280','5320','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 556, 0, 0
                    , 280, 19, 0, 0, 1, '2026-03-07 20:29:02')
                ON DUPLICATE KEY UPDATE buyprice = 280,
                        buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:02' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('556', '280', '19', '0', 'buyBillController.php', '683', '', '0', '0');
UPDATE product SET  productBuyPrice = "280" WHERE productId = 556 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 683 ;
UPDATE product SET productName = 'محجر m4/شادو2800', productDescription = '', productCatId = '15', productBuyPrice = '280.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00556',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '280',lastbuyprice_withDiscount = '280',meanbuyprice = '280',meanbuyprice_withDiscount = '280' , productbuypricereal = '280.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '42.86' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='280',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='280',meanbuyprice_withTax='280',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='280'  WHERE productId = '556';
UPDATE buybilldetail SET  lastbuyprice = 280 , meanbuyprice = 280, lastbuyprice_withDiscount = 280, meanbuyprice_withDiscount = 280
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where buybilldetailid = 683;
UPDATE productunit SET proUnitBuyPrice  = 280 * productnumber WHERE productid = 556;
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '556';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('556', '1', '19', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '19', '1', '2026-03-07 19:54:10','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 ('00557', '118', '15', '557', '28', '250', '7000.00', '0', '', '2026-03-07 20:29:02', '557','','','0','0','0','0','0',null,'250','7000','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 557, 0, 0
                    , 250, 28, 0, 0, 1, '2026-03-07 20:29:02')
                ON DUPLICATE KEY UPDATE buyprice = 250,
                        buyQuantity =buyQuantity+28, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:02' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('557', '250', '28', '0', 'buyBillController.php', '684', '', '0', '0');
UPDATE product SET  productBuyPrice = "250" WHERE productId = 557 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 684 ;
UPDATE product SET productName = 'حوض2559/لياقة/سيتي/كاندي2500', productDescription = '', productCatId = '15', productBuyPrice = '250.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00557',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '250',lastbuyprice_withDiscount = '250',meanbuyprice = '250',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '40.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='250',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='250',meanbuyprice_withTax='250',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='250'  WHERE productId = '557';
UPDATE buybilldetail SET  lastbuyprice = 250 , meanbuyprice = 250, lastbuyprice_withDiscount = 250, meanbuyprice_withDiscount = 250
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where buybilldetailid = 684;
UPDATE productunit SET proUnitBuyPrice  = 250 * productnumber WHERE productid = 557;
UPDATE storedetail SET  productquantity = '28', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '557';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('557', '1', '28', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '28', '1', '2026-03-07 19:54:10','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 ('00565', '118', '15', '565', '9', '235', '2115.00', '0', '', '2026-03-07 20:29:02', '565','','','0','0','0','0','0',null,'235','2115','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 565, 0, 0
                    , 235, 9, 0, 0, 1, '2026-03-07 20:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 235,
                        buyQuantity =buyQuantity+9, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:03' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('565', '235', '9', '0', 'buyBillController.php', '685', '', '0', '0');
UPDATE product SET  productBuyPrice = "235" WHERE productId = 565 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 685 ;
UPDATE product SET productName = 'تايسون قطن زنط2350', productDescription = '', productCatId = '15', productBuyPrice = '235.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00565',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 = '27.66' , 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',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='235'  WHERE productId = '565';
UPDATE buybilldetail SET  lastbuyprice = 235 , meanbuyprice = 235, lastbuyprice_withDiscount = 235, meanbuyprice_withDiscount = 235
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 235, lastbuyprice_withDiscountAndTax = 235
                where buybilldetailid = 685;
UPDATE productunit SET proUnitBuyPrice  = 235 * productnumber WHERE productid = 565;
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '565';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('565', '1', '9', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '9', '1', '2026-03-07 19:54:10','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 ('00559', '118', '15', '559', '24', '290', '6960.00', '0', '', '2026-03-07 20:29:02', '559','','','0','0','0','0','0',null,'290','6960','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 559, 0, 0
                    , 290, 24, 0, 0, 1, '2026-03-07 20:29:04')
                ON DUPLICATE KEY UPDATE buyprice = 290,
                        buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:04' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('559', '290', '24', '0', 'buyBillController.php', '686', '', '0', '0');
UPDATE product SET  productBuyPrice = "290" WHERE productId = 559 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 686 ;
UPDATE product SET productName = 'راوندشادو 2900', productDescription = '', productCatId = '15', productBuyPrice = '290.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00559',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '290',lastbuyprice_withDiscount = '290',meanbuyprice = '290',meanbuyprice_withDiscount = '290' , productbuypricereal = '290.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '37.93' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='290',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='290',meanbuyprice_withTax='290',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='290'  WHERE productId = '559';
UPDATE buybilldetail SET  lastbuyprice = 290 , meanbuyprice = 290, lastbuyprice_withDiscount = 290, meanbuyprice_withDiscount = 290
        , lastbuyprice_withTax = 290, meanbuyprice_withTax = 290, lastbuyprice_withDiscountAndTax = 290
                where buybilldetailid = 686;
UPDATE productunit SET proUnitBuyPrice  = 290 * productnumber WHERE productid = 559;
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '559';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('559', '1', '24', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '24', '1', '2026-03-07 19:54:10','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 ('00558', '118', '15', '558', '27', '330', '8910.00', '0', '', '2026-03-07 20:29:02', '558','','','0','0','0','0','0',null,'330','8910','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 558, 0, 0
                    , 330, 27, 0, 0, 1, '2026-03-07 20:29:04')
                ON DUPLICATE KEY UPDATE buyprice = 330,
                        buyQuantity =buyQuantity+27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:04' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('558', '330', '27', '0', 'buyBillController.php', '687', '', '0', '0');
UPDATE product SET  productBuyPrice = "330" WHERE productId = 558 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 687 ;
UPDATE product SET productName = 'شادو 3300', productDescription = '', productCatId = '15', productBuyPrice = '330.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00558',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 = '36.36' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='330',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='330'  WHERE productId = '558';
UPDATE buybilldetail SET  lastbuyprice = 330 , meanbuyprice = 330, lastbuyprice_withDiscount = 330, meanbuyprice_withDiscount = 330
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where buybilldetailid = 687;
UPDATE productunit SET proUnitBuyPrice  = 330 * productnumber WHERE productid = 558;
UPDATE storedetail SET  productquantity = '27', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '558';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('558', '1', '27', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '27', '1', '2026-03-07 19:54:10','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 ('00560', '118', '15', '560', '49', '260', '12740.00', '0', '', '2026-03-07 20:29:02', '560','','','0','0','0','0','0',null,'260','12740','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 560, 0, 0
                    , 260, 49, 0, 0, 1, '2026-03-07 20:29:05')
                ON DUPLICATE KEY UPDATE buyprice = 260,
                        buyQuantity =buyQuantity+49, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:05' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('560', '260', '49', '0', 'buyBillController.php', '688', '', '0', '0');
UPDATE product SET  productBuyPrice = "260" WHERE productId = 560 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 688 ;
UPDATE product SET productName = 'مطبوع كاندي/محجر/فقيع/ستار/سيتي/تايسون/جزار', productDescription = '', productCatId = '15', productBuyPrice = '260.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00560',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 = '34.62' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='260',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='260',meanbuyprice_withTax='260',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='260'  WHERE productId = '560';
UPDATE buybilldetail SET  lastbuyprice = 260 , meanbuyprice = 260, lastbuyprice_withDiscount = 260, meanbuyprice_withDiscount = 260
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 260, lastbuyprice_withDiscountAndTax = 260
                where buybilldetailid = 688;
UPDATE productunit SET proUnitBuyPrice  = 260 * productnumber WHERE productid = 560;
UPDATE storedetail SET  productquantity = '49', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '560';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('560', '1', '49', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '49', '1', '2026-03-07 19:54:10','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 ('00564', '118', '15', '564', '3', '210', '630.00', '0', '', '2026-03-07 20:29:02', '564','','','0','0','0','0','0',null,'210','630','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 564, 0, 0
                    , 210, 3, 0, 0, 1, '2026-03-07 20:29:05')
                ON DUPLICATE KEY UPDATE buyprice = 210,
                        buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:05' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('564', '210', '3', '0', 'buyBillController.php', '689', '', '0', '0');
UPDATE product SET  productBuyPrice = "210" WHERE productId = 564 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 689 ;
UPDATE product SET productName = 'بوكس فيت كاندي2100', productDescription = '', productCatId = '15', productBuyPrice = '210.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '250.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00564',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 = '19.05' , 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',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='210'  WHERE productId = '564';
UPDATE buybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where buybilldetailid = 689;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 564;
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '564';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('564', '1', '3', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '3', '1', '2026-03-07 19:54:10','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 ('00561', '118', '15', '561', '17', '200', '3400.00', '0', '', '2026-03-07 20:29:02', '561','','','0','0','0','0','0',null,'200','3400','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 561, 0, 0
                    , 200, 17, 0, 0, 1, '2026-03-07 20:29:05')
                ON DUPLICATE KEY UPDATE buyprice = 200,
                        buyQuantity =buyQuantity+17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:05' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('561', '200', '17', '0', 'buyBillController.php', '690', '', '0', '0');
UPDATE product SET  productBuyPrice = "200" WHERE productId = 561 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 690 ;
UPDATE product SET productName = 'سيتي/m4/تاتش', productDescription = '', productCatId = '15', productBuyPrice = '200.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00561',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200',lastbuyprice_withDiscount = '200',meanbuyprice = '200',meanbuyprice_withDiscount = '200' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '50.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',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='200',meanbuyprice_withTax='200',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='200'  WHERE productId = '561';
UPDATE buybilldetail SET  lastbuyprice = 200 , meanbuyprice = 200, lastbuyprice_withDiscount = 200, meanbuyprice_withDiscount = 200
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where buybilldetailid = 690;
UPDATE productunit SET proUnitBuyPrice  = 200 * productnumber WHERE productid = 561;
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '561';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '1', '17', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '17', '1', '2026-03-07 19:54:10','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 ('00562', '118', '15', '562', '12', '220', '2640.00', '0', '', '2026-03-07 20:29:02', '562','','','0','0','0','0','0',null,'220','2640','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 562, 0, 0
                    , 220, 12, 0, 0, 1, '2026-03-07 20:29:06')
                ON DUPLICATE KEY UPDATE buyprice = 220,
                        buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:06' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('562', '220', '12', '0', 'buyBillController.php', '691', '', '0', '0');
UPDATE product SET  productBuyPrice = "220" WHERE productId = 562 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 691 ;
UPDATE product SET productName = 'حوض مستورد2558', productDescription = '', productCatId = '15', productBuyPrice = '220.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00562',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220',lastbuyprice_withDiscount = '220',meanbuyprice = '220',meanbuyprice_withDiscount = '220' , productbuypricereal = '220.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '36.36' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='220',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='220',meanbuyprice_withTax='220',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='220'  WHERE productId = '562';
UPDATE buybilldetail SET  lastbuyprice = 220 , meanbuyprice = 220, lastbuyprice_withDiscount = 220, meanbuyprice_withDiscount = 220
        , lastbuyprice_withTax = 220, meanbuyprice_withTax = 220, lastbuyprice_withDiscountAndTax = 220
                where buybilldetailid = 691;
UPDATE productunit SET proUnitBuyPrice  = 220 * productnumber WHERE productid = 562;
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '562';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('562', '1', '12', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '12', '1', '2026-03-07 19:54:10','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 ('00563', '118', '15', '563', '4', '270', '1080.00', '0', '', '2026-03-07 20:29:02', '563','','','0','0','0','0','0',null,'270','1080','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 563, 0, 0
                    , 270, 4, 0, 0, 1, '2026-03-07 20:29:06')
                ON DUPLICATE KEY UPDATE buyprice = 270,
                        buyQuantity =buyQuantity+4, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:06' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('563', '270', '4', '0', 'buyBillController.php', '692', '', '0', '0');
UPDATE product SET  productBuyPrice = "270" WHERE productId = 563 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 692 ;
UPDATE product SET productName = 'ميلتون زونط الجزار', productDescription = '', productCatId = '15', productBuyPrice = '270.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00563',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '29.63' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='270',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='270',meanbuyprice_withTax='270',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='270'  WHERE productId = '563';
UPDATE buybilldetail SET  lastbuyprice = 270 , meanbuyprice = 270, lastbuyprice_withDiscount = 270, meanbuyprice_withDiscount = 270
        , lastbuyprice_withTax = 270, meanbuyprice_withTax = 270, lastbuyprice_withDiscountAndTax = 270
                where buybilldetailid = 692;
UPDATE productunit SET proUnitBuyPrice  = 270 * productnumber WHERE productid = 563;
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '563';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('563', '1', '4', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '4', '1', '2026-03-07 19:54:10','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 ('00566', '118', '24', '566', '15', '540', '8100.00', '0', '', '2026-03-07 20:29:02', '566','','','0','0','0','0','0',null,'540','8100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 566, 0, 0
                    , 540, 15, 0, 0, 1, '2026-03-07 20:29:07')
                ON DUPLICATE KEY UPDATE buyprice = 540,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:07' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('566', '540', '15', '0', 'buyBillController.php', '693', '', '0', '0');
UPDATE product SET  productBuyPrice = "540" WHERE productId = 566 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 693 ;
UPDATE product SET productName = 'افندينا 1102', productDescription = '', productCatId = '24', productBuyPrice = '540.00', productSellAllPrice = '750.00', productSellUnitPrice = '750.00', productSellHalfPrice = '750.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00566',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '540',lastbuyprice_withDiscount = '540',meanbuyprice = '540',meanbuyprice_withDiscount = '540' , productbuypricereal = '540.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '38.89' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='540',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='540',meanbuyprice_withTax='540',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='540'  WHERE productId = '566';
UPDATE buybilldetail SET  lastbuyprice = 540 , meanbuyprice = 540, lastbuyprice_withDiscount = 540, meanbuyprice_withDiscount = 540
        , lastbuyprice_withTax = 540, meanbuyprice_withTax = 540, lastbuyprice_withDiscountAndTax = 540
                where buybilldetailid = 693;
UPDATE productunit SET proUnitBuyPrice  = 540 * productnumber WHERE productid = 566;
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '566';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('566', '1', '15', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '1', '2026-03-07 19:54:10','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 ('00567', '118', '24', '567', '10', '450', '4500.00', '0', '', '2026-03-07 20:29:02', '567','','','0','0','0','0','0',null,'450','4500','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 567, 0, 0
                    , 450, 10, 0, 0, 1, '2026-03-07 20:29:07')
                ON DUPLICATE KEY UPDATE buyprice = 450,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:07' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('567', '450', '10', '0', 'buyBillController.php', '694', '', '0', '0');
UPDATE product SET  productBuyPrice = "450" WHERE productId = 567 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 694 ;
UPDATE product SET productName = 'شروال شرايح روبن', productDescription = '', productCatId = '24', productBuyPrice = '450.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00567',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '33.33' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '567';
UPDATE buybilldetail SET  lastbuyprice = 450 , meanbuyprice = 450, lastbuyprice_withDiscount = 450, meanbuyprice_withDiscount = 450
        , lastbuyprice_withTax = 450, meanbuyprice_withTax = 450, lastbuyprice_withDiscountAndTax = 450
                where buybilldetailid = 694;
UPDATE productunit SET proUnitBuyPrice  = 450 * productnumber WHERE productid = 567;
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '567';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('567', '1', '10', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '1', '2026-03-07 19:54:10','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 ('00568', '118', '24', '568', '5', '450', '2250.00', '0', '', '2026-03-07 20:29:02', '568','','','0','0','0','0','0',null,'450','2250','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 568, 0, 0
                    , 450, 5, 0, 0, 1, '2026-03-07 20:29:08')
                ON DUPLICATE KEY UPDATE buyprice = 450,
                        buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:08' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('568', '450', '5', '0', 'buyBillController.php', '695', '', '0', '0');
UPDATE product SET  productBuyPrice = "450" WHERE productId = 568 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 695 ;
UPDATE product SET productName = 'شروال جينز5024', productDescription = '', productCatId = '24', productBuyPrice = '450.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00568',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '33.33' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '568';
UPDATE buybilldetail SET  lastbuyprice = 450 , meanbuyprice = 450, lastbuyprice_withDiscount = 450, meanbuyprice_withDiscount = 450
        , lastbuyprice_withTax = 450, meanbuyprice_withTax = 450, lastbuyprice_withDiscountAndTax = 450
                where buybilldetailid = 695;
UPDATE productunit SET proUnitBuyPrice  = 450 * productnumber WHERE productid = 568;
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '568';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('568', '1', '5', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '5', '1', '2026-03-07 19:54:10','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 ('00569', '118', '24', '569', '15', '475', '7125.00', '0', '', '2026-03-07 20:29:02', '569','','','0','0','0','0','0',null,'475','7125','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 569, 0, 0
                    , 475, 15, 0, 0, 1, '2026-03-07 20:29:08')
                ON DUPLICATE KEY UPDATE buyprice = 475,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:08' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('569', '475', '15', '0', 'buyBillController.php', '696', '', '0', '0');
UPDATE product SET  productBuyPrice = "475" WHERE productId = 569 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 696 ;
UPDATE product SET productName = 'الو لورد', productDescription = '', productCatId = '24', productBuyPrice = '475.00', productSellAllPrice = '650.00', productSellUnitPrice = '650.00', productSellHalfPrice = '650.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00569',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '475',lastbuyprice_withDiscount = '475',meanbuyprice = '475',meanbuyprice_withDiscount = '475' , productbuypricereal = '475.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '36.84' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='475',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='475',meanbuyprice_withTax='475',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='475'  WHERE productId = '569';
UPDATE buybilldetail SET  lastbuyprice = 475 , meanbuyprice = 475, lastbuyprice_withDiscount = 475, meanbuyprice_withDiscount = 475
        , lastbuyprice_withTax = 475, meanbuyprice_withTax = 475, lastbuyprice_withDiscountAndTax = 475
                where buybilldetailid = 696;
UPDATE productunit SET proUnitBuyPrice  = 475 * productnumber WHERE productid = 569;
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '569';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('569', '1', '15', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '1', '2026-03-07 19:54:10','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 ('00570', '118', '24', '570', '5', '450', '2250.00', '0', '', '2026-03-07 20:29:02', '570','','','0','0','0','0','0',null,'450','2250','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 570, 0, 0
                    , 450, 5, 0, 0, 1, '2026-03-07 20:29:08')
                ON DUPLICATE KEY UPDATE buyprice = 450,
                        buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:08' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('570', '450', '5', '0', 'buyBillController.php', '697', '', '0', '0');
UPDATE product SET  productBuyPrice = "450" WHERE productId = 570 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 697 ;
UPDATE product SET productName = 'شروال جينز5022', productDescription = '', productCatId = '24', productBuyPrice = '450.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00570',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '33.33' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '570';
UPDATE buybilldetail SET  lastbuyprice = 450 , meanbuyprice = 450, lastbuyprice_withDiscount = 450, meanbuyprice_withDiscount = 450
        , lastbuyprice_withTax = 450, meanbuyprice_withTax = 450, lastbuyprice_withDiscountAndTax = 450
                where buybilldetailid = 697;
UPDATE productunit SET proUnitBuyPrice  = 450 * productnumber WHERE productid = 570;
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '570';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('570', '1', '5', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '5', '1', '2026-03-07 19:54:10','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 ('00571', '118', '24', '571', '10', '560', '5600.00', '0', '', '2026-03-07 20:29:02', '571','','','0','0','0','0','0',null,'560','5600','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 571, 0, 0
                    , 560, 10, 0, 0, 1, '2026-03-07 20:29:08')
                ON DUPLICATE KEY UPDATE buyprice = 560,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:08' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('571', '560', '10', '0', 'buyBillController.php', '698', '', '0', '0');
UPDATE product SET  productBuyPrice = "560" WHERE productId = 571 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 698 ;
UPDATE product SET productName = 'افندينا1111', productDescription = '', productCatId = '24', productBuyPrice = '560.00', productSellAllPrice = '700.00', productSellUnitPrice = '700.00', productSellHalfPrice = '700.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00571',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '560',lastbuyprice_withDiscount = '560',meanbuyprice = '560',meanbuyprice_withDiscount = '560' , productbuypricereal = '560.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='560',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='560',meanbuyprice_withTax='560',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='560'  WHERE productId = '571';
UPDATE buybilldetail SET  lastbuyprice = 560 , meanbuyprice = 560, lastbuyprice_withDiscount = 560, meanbuyprice_withDiscount = 560
        , lastbuyprice_withTax = 560, meanbuyprice_withTax = 560, lastbuyprice_withDiscountAndTax = 560
                where buybilldetailid = 698;
UPDATE productunit SET proUnitBuyPrice  = 560 * productnumber WHERE productid = 571;
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '571';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('571', '1', '10', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '1', '2026-03-07 19:54:10','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 ('00572', '118', '12', '572', '14', '400', '5600.00', '0', '', '2026-03-07 20:29:02', '572','','','0','0','0','0','0',null,'400','5600','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 572, 0, 0
                    , 400, 14, 0, 0, 1, '2026-03-07 20:29:09')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:09' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('572', '400', '14', '0', 'buyBillController.php', '699', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 572 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 699 ;
UPDATE product SET productName = 'جاكت افريكانو/دودج', productDescription = '', productCatId = '12', productBuyPrice = '400.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00572',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 = '12.50' , 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',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',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='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='400'  WHERE productId = '572';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 699;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 572;
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '572';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('572', '1', '14', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '14', '1', '2026-03-07 19:54:10','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 ('00538', '118', '24', '538', '50', '250', '12500.00', '0', '', '2026-03-07 20:29:02', '538','','','0','0','0','0','0',null,'250','12500','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 538, 0, 0
                    , 250, 50, 0, 0, 1, '2026-03-07 20:29:09')
                ON DUPLICATE KEY UPDATE buyprice = 250,
                        buyQuantity =buyQuantity+50, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:09' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('538', '250', '50', '0', 'buyBillController.php', '700', '', '0', '0');
UPDATE product SET  productBuyPrice = "250" WHERE productId = 538 ;
UPDATE buybilldetail SET  quantitybefore = 25 WHERE buybilldetailid = 700 ;
UPDATE product SET productName = 'جينز عرض جديد 300', productDescription = '', productCatId = '24', productBuyPrice = '250.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2026-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '00538',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '250',lastbuyprice_withDiscount = '250',meanbuyprice = '250',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '20.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='250',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='250',meanbuyprice_withTax='250',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='250'  WHERE productId = '538';
UPDATE buybilldetail SET  lastbuyprice = 250 , meanbuyprice = 250, lastbuyprice_withDiscount = 250, meanbuyprice_withDiscount = 250
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where buybilldetailid = 700;
UPDATE productunit SET proUnitBuyPrice  = 250 * productnumber WHERE productid = 538;
UPDATE storedetail SET  productquantity = '75', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '538';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('538', '1', '50', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '25', '75', '1', '2026-03-07 19:54:10','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 ('00548', '118', '12', '548', '25', '390', '9750.00', '0', '', '2026-03-07 20:29:02', '548','','','0','0','0','0','0',null,'390','9750','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 548, 0, 0
                    , 390, 25, 0, 0, 1, '2026-03-07 20:29:10')
                ON DUPLICATE KEY UPDATE buyprice = 390,
                        buyQuantity =buyQuantity+25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:10' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('548', '390', '25', '0', 'buyBillController.php', '701', '', '0', '0');
UPDATE product SET  productBuyPrice = "390" WHERE productId = 548 ;
UPDATE buybilldetail SET  quantitybefore = 3 WHERE buybilldetailid = 701 ;
UPDATE product SET productName = 'جاكت عرض المصري', productDescription = '', productCatId = '12', productBuyPrice = '390.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2026-03-04', conditions = '0', userId = '1', limitamount = '0', parcode = '00548',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '390',lastbuyprice_withDiscount = '390',meanbuyprice = '390',meanbuyprice_withDiscount = '390' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '15.38' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='390',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='390',meanbuyprice_withTax='390',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='390'  WHERE productId = '548';
UPDATE buybilldetail SET  lastbuyprice = 390 , meanbuyprice = 390, lastbuyprice_withDiscount = 390, meanbuyprice_withDiscount = 390
        , lastbuyprice_withTax = 390, meanbuyprice_withTax = 390, lastbuyprice_withDiscountAndTax = 390
                where buybilldetailid = 701;
UPDATE productunit SET proUnitBuyPrice  = 390 * productnumber WHERE productid = 548;
UPDATE storedetail SET  productquantity = '28', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '548';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('548', '1', '25', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '3', '28', '1', '2026-03-07 19:54:10','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 ('00573', '118', '2', '573', '12', '315', '3780.00', '0', '', '2026-03-07 20:29:02', '573','','','0','0','0','0','0',null,'315','3780','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 573, 0, 0
                    , 315, 12, 0, 0, 1, '2026-03-07 20:29:10')
                ON DUPLICATE KEY UPDATE buyprice = 315,
                        buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:10' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('573', '315', '12', '0', 'buyBillController.php', '702', '', '0', '0');
UPDATE product SET  productBuyPrice = "315" WHERE productId = 573 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 702 ;
UPDATE product SET productName = 'شروال محجرتقطيع جديد', productDescription = '', productCatId = '2', productBuyPrice = '315.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00573',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '315',lastbuyprice_withDiscount = '315',meanbuyprice = '315',meanbuyprice_withDiscount = '315' , productbuypricereal = '315.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '58.73' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='315',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='315',meanbuyprice_withTax='315',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='315'  WHERE productId = '573';
UPDATE buybilldetail SET  lastbuyprice = 315 , meanbuyprice = 315, lastbuyprice_withDiscount = 315, meanbuyprice_withDiscount = 315
        , lastbuyprice_withTax = 315, meanbuyprice_withTax = 315, lastbuyprice_withDiscountAndTax = 315
                where buybilldetailid = 702;
UPDATE productunit SET proUnitBuyPrice  = 315 * productnumber WHERE productid = 573;
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '573';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('573', '1', '12', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '12', '1', '2026-03-07 19:54:10','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 ('00574', '118', '24', '574', '5', '450', '2250.00', '0', '', '2026-03-07 20:29:02', '574','','','0','0','0','0','0',null,'450','2250','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2026-03-07 19:54:10', 1, 574, 0, 0
                    , 450, 5, 0, 0, 1, '2026-03-07 20:29:11')
                ON DUPLICATE KEY UPDATE buyprice = 450,
                        buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2026-03-07 20:29:11' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('574', '450', '5', '0', 'buyBillController.php', '703', '', '0', '0');
UPDATE product SET  productBuyPrice = "450" WHERE productId = 574 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 703 ;
UPDATE product SET productName = 'شروال سوبر باجي روبن', productDescription = '', productCatId = '24', productBuyPrice = '450.00', productSellAllPrice = '650.00', productSellUnitPrice = '650.00', productSellHalfPrice = '650.00', productDate = '2026-03-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00574',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '44.44' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='450',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',webApiId='0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',itemsymbol='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='450',meanbuyprice_withTax='450',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='450'  WHERE productId = '574';
UPDATE buybilldetail SET  lastbuyprice = 450 , meanbuyprice = 450, lastbuyprice_withDiscount = 450, meanbuyprice_withDiscount = 450
        , lastbuyprice_withTax = 450, meanbuyprice_withTax = 450, lastbuyprice_withDiscountAndTax = 450
                where buybilldetailid = 703;
UPDATE productunit SET proUnitBuyPrice  = 450 * productnumber WHERE productid = 574;
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2026-03-07' WHERE storedetailid = '574';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('574', '1', '5', '0', '118', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '5', '1', '2026-03-07 19:54:10','0','0');
UPDATE supplier SET  suppliercurrentDebt = '1681182',suppliercurrentDebtInCurrency= '1681182' , userid = '1', supplierdate = '2026-03-07 20:29:02'   WHERE supplierid = '1';
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 ('1', '1566682.00', '114500', '0', 'اضافة فاتورة مشتريات', '118', '1681182', '2026-03-07 19:54:10', '1', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','114500','1','1566682','114500','1681182','0');
update buybill set dailyentryid='0,0' where buybillid=118;
COMMIT;
UPDATE product SET overAllAveragePrice = 250 WHERE productId = 538;UPDATE product SET overAllAveragePrice = 390 WHERE productId = 548;UPDATE product SET overAllAveragePrice = 280 WHERE productId = 556;UPDATE product SET overAllAveragePrice = 250 WHERE productId = 557;UPDATE product SET overAllAveragePrice = 330 WHERE productId = 558;UPDATE product SET overAllAveragePrice = 290 WHERE productId = 559;UPDATE product SET overAllAveragePrice = 260 WHERE productId = 560;UPDATE product SET overAllAveragePrice = 200 WHERE productId = 561;UPDATE product SET overAllAveragePrice = 220 WHERE productId = 562;UPDATE product SET overAllAveragePrice = 270 WHERE productId = 563;UPDATE product SET overAllAveragePrice = 210 WHERE productId = 564;UPDATE product SET overAllAveragePrice = 235 WHERE productId = 565;UPDATE product SET overAllAveragePrice = 540 WHERE productId = 566;UPDATE product SET overAllAveragePrice = 450 WHERE productId = 567;UPDATE product SET overAllAveragePrice = 450 WHERE productId = 568;UPDATE product SET overAllAveragePrice = 475 WHERE productId = 569;UPDATE product SET overAllAveragePrice = 450 WHERE productId = 570;UPDATE product SET overAllAveragePrice = 560 WHERE productId = 571;UPDATE product SET overAllAveragePrice = 400 WHERE productId = 572;UPDATE product SET overAllAveragePrice = 315 WHERE productId = 573;UPDATE product SET overAllAveragePrice = 450 WHERE productId = 574;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 16:59:12";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:29:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2026-03-07 20:29:12', '1', 'bill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:00:40";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:30:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:30:40', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:01:24";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:31:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:31:25', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:01:59";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:31:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:31:59', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:02:59";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:32:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:32:59', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:03:47";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:33:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:33:47', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:04:25";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:34:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:34:25', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:05:07";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:35:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:35:07', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:05:39";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:35:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:35:39', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:06:12";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:36:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:36:12', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:06:45";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:36:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:36:45', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:07:41";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:37:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:37:41', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:08:06";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:38:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:38:06', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:08:29";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:38:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:38:29', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:09:12";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:39:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:39:12', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:10:08";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:40:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:40:08', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:10:55";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:40:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:40:55', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac7108e4f0b
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 20:40:08', '069ac7108e4f0b', '1', '0.00', '0', '0', '1', '600.00', '600', '600', '0', '1', '2026-03-07 20:40:55', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','600','0','','0','0','600','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4857', '0', '2026-03-07 20:40:55', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '600', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 20:40:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 661;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00538', '4857', '24', '538', '2', '300', '600.00', '0', '', '0', '2026-03-07 20:40:56', '538', '0.00', '0', '1','0.00','','','0','0','0','0','0','0','0','0','','661-2,','1','1','0','0','300','600','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 = 7380;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (538, '2026-03-07', 600, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+500
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+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, '2026-03-07', 600, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+500
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '73', userid = '1', storedetaildate = '2026-03-07 20:40:56' WHERE storedetailid = '538';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('538', '1', '2', '1', '4857', 'اضافة فاتورة مبيعات', 'sellbillController.php', '75', '73', '1', '2026-03-07 20:40:56','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2715738',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2715138','600', '0', '1', 'اضافة فاتورة مبيعات', '4857', '2715738', '2026-03-07 20:40:56', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '600', '600', '2026-03-07', '1', '0', '0', '2026-03-07 20:40:56','اضافة فاتورة مبيعات رقم 4857','1','0',null,'0','4857','sellbillController.php?do=showDetail&sellbillid=4857');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10839', '383', '600', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2714738', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10839', '143', '600', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2818735', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '500', '500', '2026-03-07', '1', '0', '0', '2026-03-07 20:40:56','اضافة فاتورة مبيعات رقم 4857 - صرف البضاعة من المخزن','1','0',null,'0','4857','sellbillController.php?do=showDetail&sellbillid=4857');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10840', '402', '500', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2003313.63', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10840', '382', '500', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1138708.13', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10839,0,10840' where sellbillid=4857;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 600, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+500
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 600, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+500
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 600, 500, 500
                    , 500, 500, 500, 500, 500, 500)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+600, 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 069ac7108e4f0b and sellbillId = 4857 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:10:57";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:40:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:40:57', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:11:11";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:41:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:41:12', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:11:41";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:41:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:41:41', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:12:12";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:42:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:42:12', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:12:47";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:42:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:42:47', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac7139ba009
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 20:40:57', '069ac7139ba009', '1', '0.00', '0', '50', '1', '750.00', '700', '700', '0', '1', '2026-03-07 20:42:48', '', '1', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','700','0','','0','0','700','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4858', '0', '2026-03-07 20:42:48', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '700', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 20:40:57','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 668;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00543', '4858', '6', '543', '1', '750', '750.00', '0', '', '0', '2026-03-07 20:42:48', '543', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','668-1,','1','1','0','0','750','750','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 550.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 550.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 550, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 7381;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (543, '2026-03-07', 700, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 700, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2026-03-07 20:42:48' WHERE storedetailid = '543';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('543', '1', '1', '1', '4858', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '1', '2026-03-07 20:42:48','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2716438',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2715738','700', '0', '1', 'اضافة فاتورة مبيعات', '4858', '2716438', '2026-03-07 20:42:48', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '750', '750', '2026-03-07', '1', '0', '0', '2026-03-07 20:42:48','اضافة فاتورة مبيعات رقم 4858','1','0',null,'0','4858','sellbillController.php?do=showDetail&sellbillid=4858');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10841', '383', '700', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2715438', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10841', '398', '50', '','0');
UPDATE accountstree SET name = 'خصم مسموح به', customName = 'خصم مسموح به', customNameEn = '', nameEn = '', parent = '158', accountNature = '0', theValue = '52450', theOrder = '0', layingOrder = '51', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-08-08 17:58:26' WHERE id = '398';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10841', '143', '750', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2819485', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '550', '550', '2026-03-07', '1', '0', '0', '2026-03-07 20:42:48','اضافة فاتورة مبيعات رقم 4858 - صرف البضاعة من المخزن','1','0',null,'0','4858','sellbillController.php?do=showDetail&sellbillid=4858');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10842', '402', '550', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2003863.63', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10842', '382', '550', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1139258.13', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10841,0,10842' where sellbillid=4858;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 700, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 700, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 700, 550, 550
                    , 550, 550, 550, 550, 550, 550)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+700, netSellCostBuyPrice = netSellCostBuyPrice+550
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+550
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+550
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+550
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+550
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+550
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+550
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+550;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac7139ba009 and sellbillId = 4858 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:12:49";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:42:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 20:42:49', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:14:36";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:44:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:44:36', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:15:26";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:45:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:45:26', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:15:54";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:45:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:45:54', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 17:16:34";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 20:46:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2026-03-07 20:46:34', '1', 'showbarcode', '::1', '', 'DESKTOP','https://localhost/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:03:52";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:33:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:33:53', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:04:13";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:34:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:34:13', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac7da1bfad4
-- ----------------------------------------------------------------------------------------------------

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,returnsellbilltypeclientid) VALUES ('2026-03-07 21:33:53', '069ac7da1bfad4', '1', '0.00', '0', '0', '1', '650', '650', '-650', '0', '1', '2026-03-07 21:34:14', '', '1', '0', 'نقدي','1', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-650','0','0','0','0','0','0','0','0','-1','0','0','1','','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, 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','اضافة فاتورة مردوات مبيعات','503', '0', '2026-03-07 21:34:14', '1', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '650', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:33:53','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 ('560.00', '00383', '503', '6', '383', '1', '650', '650', '0', '', '0', '0', '383', '0.00', '-1','1','0','','','0','0','0','0','0','0','1','1','','0','0','650','650','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 560.00 , meanbuyprice = 419.78, lastbuyprice_withDiscount = 560.00, meanbuyprice_withDiscount = 419.78
        , lastbuyprice_withTax = 560, meanbuyprice_withTax = 283.55, lastbuyprice_withDiscountAndTax = 560
                where returnsellbilldetailid = 567;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (383, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 650, 560, 560, 419.78
                    , 560, 419.78, 554.15, 0, 1, 0, 0, 560, 283.55)
                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+560, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+560
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+419.78, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+560
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+419.78
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+554.15
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+560
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+283.55
                        , 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, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 650, 560, 560, 419.78
                    , 560, 419.78, 554.15, 0, 0, 560, 283.55)
                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+560, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+560
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+419.78, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+560
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+419.78
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+554.15
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+560
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+283.55;
UPDATE storedetail SET  productquantity = '-17', userid = '1', storedetaildate = '2026-03-07 21:34:14' WHERE storedetailid = '383';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('383', '1', '1', '0', '503', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-18', '-17', '1', '2026-03-07 21:34:14','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2715788',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2716438','-650', '1', '1', 'اضافة فاتورة مردوات مبيعات', '503', '2715788', '2026-03-07 21:34:14', '1',  'returnsellbillController.php','1','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '650', '650', '2026-03-07', '1', '0', '0', '2026-03-07 21:34:14','اضافة فاتورة مردود مبيعات رقم 503','1','0',null,'0','503','returnsellbillController.php?do=showDetail&returnsellbillid=503');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10843', '143', '650', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2818835', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10843', '383', '650', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2714788', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '560', '560', '2026-03-07', '1', '0', '0', '2026-03-07 21:34:14','اضافة فاتورة مردود مبيعات رقم 503 - صرف البضاعة من المخزن','1','0',null,'0','503','returnsellbillController.php?do=showDetail&returnsellbillid=503');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10844', '382', '560', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1138698.13', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10844', '402', '560', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2003303.63', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
update returnsellbill set dailyentryid='10843,0,10844' where returnsellbillid=503;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 650, 560, 560, 419.78
                    , 560, 419.78, 554.15 ,0, 0, 560, 283.55)
                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+560, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+560
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+419.78, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+560
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+419.78
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+554.15
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+560
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+283.55;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 650, 560, 560, 419.78
                    , 560, 419.78, 554.15 ,0, 0, 560, 283.55)
                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+560, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+560
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+419.78, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+560
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+419.78
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+554.15
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+560
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+283.55;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -650, -560, -560
                    , -419.78, -560, -419.78, -554.15, -560, -283.55)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-650, netSellCostBuyPrice = netSellCostBuyPrice+-560
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-560
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-419.78
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-560
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-419.78
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-554.15
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-560
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-283.55;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac7da1bfad4 and sellbillId = 503 and returnsellbillId = 503
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:04:15";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:34:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:34:15', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:04:19";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:34:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:34:19', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:05:59";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:35:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:35:59', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac7dbc3e0d7
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 21:34:20', '069ac7dbc3e0d7', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2026-03-07 21:35:59', '', '1', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4859', '0', '2026-03-07 21:35:59', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:34:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 638;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('239.96','00520', '4859', '15', '520', '1', '300', '300.00', '0', '', '0', '2026-03-07 21:35:59', '520', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','638-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 = 239.96, meanbuyprice_withDiscount = 239.96
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 239.96
                where sellbilldetailid = 7382;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (520, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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 = '77', userid = '1', storedetaildate = '2026-03-07 21:35:59' WHERE storedetailid = '520';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('520', '1', '1', '1', '4859', 'اضافة فاتورة مبيعات', 'sellbillController.php', '78', '77', '1', '2026-03-07 21:35:59','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2716088',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2715788','300', '0', '1', 'اضافة فاتورة مبيعات', '4859', '2716088', '2026-03-07 21:36:00', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '300', '300', '2026-03-07', '1', '0', '0', '2026-03-07 21:36:00','اضافة فاتورة مبيعات رقم 4859','1','0',null,'0','4859','sellbillController.php?do=showDetail&sellbillid=4859');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10845', '383', '300', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2715088', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10845', '143', '300', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2819135', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '239.96', '239.96', '2026-03-07', '1', '0', '0', '2026-03-07 21:36:00','اضافة فاتورة مبيعات رقم 4859 - صرف البضاعة من المخزن','1','0',null,'0','4859','sellbillController.php?do=showDetail&sellbillid=4859');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10846', '402', '239.96', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2003543.59', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10846', '382', '239.96', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1138938.09', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10845,0,10846' where sellbillid=4859;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, 239.96, 239.96, 239.96, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+240
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+240
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+239.96
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+239.96
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+239.96
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+240
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+240;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac7dbc3e0d7 and sellbillId = 4859 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:06:00";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:36:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:36:00', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:10:34";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:40:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:40:34', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac7e21aa608
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 21:36:01', '069ac7e21aa608', '1', '0.00', '0', '0', '1', '800.00', '800', '800', '0', '1', '2026-03-07 21:40:34', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','800','0','','0','0','800','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4860', '0', '2026-03-07 21:40:35', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:36:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 517;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00217', '4860', '1', '217', '1', '500', '500.00', '0', '', '0', '2026-03-07 21:40:35', '217', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','517-1,','1','1','0','0','500','500','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 = 7383;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (217, '2026-03-07', 500, 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+500, 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, '2026-03-07', 500, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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 = '11', userid = '1', storedetaildate = '2026-03-07 21:40:35' WHERE storedetailid = '217';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('217', '1', '1', '1', '4860', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '1', '2026-03-07 21:40:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 638;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('239.96','00520', '4860', '15', '520', '1', '300', '300.00', '0', '', '0', '2026-03-07 21:40:35', '520', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','638-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 = 239.96, meanbuyprice_withDiscount = 239.96
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 239.96
                where sellbilldetailid = 7384;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (520, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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 = '76', userid = '1', storedetaildate = '2026-03-07 21:40:35' WHERE storedetailid = '520';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('520', '1', '1', '1', '4860', 'اضافة فاتورة مبيعات', 'sellbillController.php', '77', '76', '1', '2026-03-07 21:40:35','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2716888',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2716088','800', '0', '1', 'اضافة فاتورة مبيعات', '4860', '2716888', '2026-03-07 21:40:35', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '800', '800', '2026-03-07', '1', '0', '0', '2026-03-07 21:40:36','اضافة فاتورة مبيعات رقم 4860','1','0',null,'0','4860','sellbillController.php?do=showDetail&sellbillid=4860');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10847', '383', '800', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2715888', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10847', '143', '800', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2819935', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '559.96', '559.96', '2026-03-07', '1', '0', '0', '2026-03-07 21:40:36','اضافة فاتورة مبيعات رقم 4860 - صرف البضاعة من المخزن','1','0',null,'0','4860','sellbillController.php?do=showDetail&sellbillid=4860');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10848', '402', '559.96', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2004103.55', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10848', '382', '559.96', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1139498.05', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10847,0,10848' where sellbillid=4860;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 800, 560, 560
                    , 560, 559.96, 559.96, 559.96
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,560, 560, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+559.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+559.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+559.96
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+560
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 800, 560, 560
                    , 560, 559.96, 559.96, 559.96
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,560, 560, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+560
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+560, sellCostMeanBuyPrice = sellCostMeanBuyPrice+560
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+559.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+559.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+559.96
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+560
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+560
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 800, 560, 560
                    , 560, 559.96, 559.96, 559.96, 560, 560)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+800, netSellCostBuyPrice = netSellCostBuyPrice+560
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+560
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+560
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+559.96
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+559.96
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+559.96
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+560
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+560;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac7e21aa608 and sellbillId = 4860 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:10:36";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:40:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:40:36', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:12:45";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:42:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:42:46', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:13:25";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:43:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:43:25', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac7fb6c7c23
-- ----------------------------------------------------------------------------------------------------

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,returnsellbilltypeclientid) VALUES ('2026-03-07 21:42:46', '069ac7fb6c7c23', '1', '0.00', '0', '0', '1', '250', '250', '-250', '0', '1', '2026-03-07 21:43:25', '', '1', '0', 'نقدي','1', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-250','0','0','0','0','0','0','0','0','-1','0','0','1','','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, 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','اضافة فاتورة مردوات مبيعات','504', '0', '2026-03-07 21:43:26', '1', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '250', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:42:46','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 ('115.00', '00552', '504', '18', '552', '1', '250', '250', '0', '', '0', '0', '552', '0.00', '-1','1','0','','','0','0','0','0','0','0','1','1','','0','0','250','250','0','','0');
UPDATE returnsellbilldetail 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 returnsellbilldetailid = 568;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (552, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 115, 115, 115
                    , 115, 115, 115, 0, 1, 0, 0, 115, 115)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+250, returnSellCostBuyPrice = returnSellCostBuyPrice+115, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+115
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+115, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+115
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+115
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+115
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+115
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+115
                        , 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, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 115, 115, 115
                    , 115, 115, 115, 0, 0, 115, 115)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+250, returnSellCostBuyPrice = returnSellCostBuyPrice+115, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+115
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+115, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+115
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+115
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+115
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+115
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+115;
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2026-03-07 21:43:26' WHERE storedetailid = '552';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('552', '1', '1', '0', '504', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '5', '6', '1', '2026-03-07 21:43:26','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2716638',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2716888','-250', '1', '1', 'اضافة فاتورة مردوات مبيعات', '504', '2716638', '2026-03-07 21:43:26', '1',  'returnsellbillController.php','1','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '250', '250', '2026-03-07', '1', '0', '0', '2026-03-07 21:43:26','اضافة فاتورة مردود مبيعات رقم 504','1','0',null,'0','504','returnsellbillController.php?do=showDetail&returnsellbillid=504');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10849', '143', '250', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2819685', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10849', '383', '250', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2715638', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '115', '115', '2026-03-07', '1', '0', '0', '2026-03-07 21:43:26','اضافة فاتورة مردود مبيعات رقم 504 - صرف البضاعة من المخزن','1','0',null,'0','504','returnsellbillController.php?do=showDetail&returnsellbillid=504');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10850', '382', '115', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1139383.05', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10850', '402', '115', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2003988.55', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
update returnsellbill set dailyentryid='10849,0,10850' where returnsellbillid=504;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 115, 115, 115
                    , 115, 115, 115 ,0, 0, 115, 115)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+250, returnSellCostBuyPrice = returnSellCostBuyPrice+115, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+115
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+115, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+115
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+115
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+115
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+115
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+115;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 115, 115, 115
                    , 115, 115, 115 ,0, 0, 115, 115)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+250, returnSellCostBuyPrice = returnSellCostBuyPrice+115, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+115
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+115, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+115
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+115
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+115
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+115
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+115;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -250, -115, -115
                    , -115, -115, -115, -115, -115, -115)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-250, netSellCostBuyPrice = netSellCostBuyPrice+-115
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-115
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-115
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-115
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-115
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-115
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-115
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-115;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac7fb6c7c23 and sellbillId = 504 and returnsellbillId = 504
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:13:27";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:43:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:43:27', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:13:31";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:43:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:43:31', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:13:45";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:43:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:43:45', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac7fe47bf73
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 21:43:32', '069ac7fe47bf73', '1', '0.00', '0', '0', '1', '250.00', '250', '250', '0', '1', '2026-03-07 21:43:45', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4861', '0', '2026-03-07 21:43:46', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '250', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:43:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 678;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('125','00551', '4861', '18', '551', '1', '250', '250.00', '0', '', '0', '2026-03-07 21:43:46', '551', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','678-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 125.00 , meanbuyprice = 125.00, lastbuyprice_withDiscount = 125.00, meanbuyprice_withDiscount = 125.00
        , lastbuyprice_withTax = 125, meanbuyprice_withTax = 125, lastbuyprice_withDiscountAndTax = 125
                where sellbilldetailid = 7385;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (551, '2026-03-07', 250, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 250, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2026-03-07 21:43:46' WHERE storedetailid = '551';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('551', '1', '1', '1', '4861', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '1', '2026-03-07 21:43:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2716888',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2716638','250', '0', '1', 'اضافة فاتورة مبيعات', '4861', '2716888', '2026-03-07 21:43:46', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '250', '250', '2026-03-07', '1', '0', '0', '2026-03-07 21:43:46','اضافة فاتورة مبيعات رقم 4861','1','0',null,'0','4861','sellbillController.php?do=showDetail&sellbillid=4861');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10851', '383', '250', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2715888', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10851', '143', '250', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2819935', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '125', '125', '2026-03-07', '1', '0', '0', '2026-03-07 21:43:46','اضافة فاتورة مبيعات رقم 4861 - صرف البضاعة من المخزن','1','0',null,'0','4861','sellbillController.php?do=showDetail&sellbillid=4861');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10852', '402', '125', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2004113.55', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10852', '382', '125', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1139508.05', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10851,0,10852' where sellbillid=4861;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 250, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 250, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 250, 125, 125
                    , 125, 125, 125, 125, 125, 125)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+250, netSellCostBuyPrice = netSellCostBuyPrice+125
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+125
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+125
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+125
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+125
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+125
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+125
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+125;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac7fe47bf73 and sellbillId = 4861 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:13:47";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:43:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:43:47', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:18:54";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:48:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:48:54', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:19:06";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:49:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:49:06', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac8126b7906
-- ----------------------------------------------------------------------------------------------------

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,returnsellbilltypeclientid) VALUES ('2026-03-07 21:48:54', '069ac8126b7906', '1', '0.00', '0', '0', '1', '300', '300', '-300', '0', '1', '2026-03-07 21:49:06', '', '1', '0', 'نقدي','1', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-300','0','0','0','0','0','0','0','0','-1','0','0','1','','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, 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','اضافة فاتورة مردوات مبيعات','505', '0', '2026-03-07 21:49:06', '1', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:48:54','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('375.00', '00420', '505', '15', '420', '1', '300', '300', '0', '', '0', '0', '420', '0.00', '-1','1','0','','','0','0','0','0','0','0','1','1','','0','0','300','300','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 374.25, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 374.25
        , lastbuyprice_withTax = 375, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 375
                where returnsellbilldetailid = 569;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (420, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 300, 375, 375, 374.25
                    , 375, 374.25, 375, 0, 1, 0, 0, 375, 375)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+300, returnSellCostBuyPrice = returnSellCostBuyPrice+375, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+375
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+374.25, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+375
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+374.25
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+375
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+375
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+375
                        , 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, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 300, 375, 375, 374.25
                    , 375, 374.25, 375, 0, 0, 375, 375)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+300, returnSellCostBuyPrice = returnSellCostBuyPrice+375, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+375
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+374.25, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+375
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+374.25
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+375
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+375
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+375;
UPDATE storedetail SET  productquantity = '-14', userid = '1', storedetaildate = '2026-03-07 21:49:06' WHERE storedetailid = '420';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('420', '1', '1', '0', '505', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-15', '-14', '1', '2026-03-07 21:49:06','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2716588',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2716888','-300', '1', '1', 'اضافة فاتورة مردوات مبيعات', '505', '2716588', '2026-03-07 21:49:06', '1',  'returnsellbillController.php','1','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '300', '300', '2026-03-07', '1', '0', '0', '2026-03-07 21:49:06','اضافة فاتورة مردود مبيعات رقم 505','1','0',null,'0','505','returnsellbillController.php?do=showDetail&returnsellbillid=505');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10853', '143', '300', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2819635', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10853', '383', '300', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2715588', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '375', '375', '2026-03-07', '1', '0', '0', '2026-03-07 21:49:06','اضافة فاتورة مردود مبيعات رقم 505 - صرف البضاعة من المخزن','1','0',null,'0','505','returnsellbillController.php?do=showDetail&returnsellbillid=505');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10854', '382', '375', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1139133.05', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10854', '402', '375', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2003738.55', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
update returnsellbill set dailyentryid='10853,0,10854' where returnsellbillid=505;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 300, 375, 375, 374.25
                    , 375, 374.25, 375 ,0, 0, 375, 375)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+300, returnSellCostBuyPrice = returnSellCostBuyPrice+375, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+375
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+374.25, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+375
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+374.25
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+375
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+375
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+375;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 300, 375, 375, 374.25
                    , 375, 374.25, 375 ,0, 0, 375, 375)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+300, returnSellCostBuyPrice = returnSellCostBuyPrice+375, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+375
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+374.25, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+375
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+374.25
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+375
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+375
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+375;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -300, -375, -375
                    , -374.25, -375, -374.25, -375, -375, -375)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-300, netSellCostBuyPrice = netSellCostBuyPrice+-375
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-375
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-374.25
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-375
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-374.25
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-375
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-375
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-375;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac8126b7906 and sellbillId = 505 and returnsellbillId = 505
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:19:07";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:49:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:49:07', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:19:30";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:49:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:49:30', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:20:07";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:50:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:50:07', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac814b6f285
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 21:49:31', '069ac814b6f285', '1', '0.00', '0', '0', '1', '750.00', '750', '750', '0', '1', '2026-03-07 21:50:08', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','750','0','','0','0','750','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4862', '0', '2026-03-07 21:50:08', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '750', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:49:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 670;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('580','00545', '4862', '6', '545', '1', '750', '750.00', '0', '', '0', '2026-03-07 21:50:08', '545', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','670-1,','1','1','0','0','750','750','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 580.00 , meanbuyprice = 580.00, lastbuyprice_withDiscount = 580.00, meanbuyprice_withDiscount = 580.00
        , lastbuyprice_withTax = 580, meanbuyprice_withTax = 580, lastbuyprice_withDiscountAndTax = 580
                where sellbilldetailid = 7386;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (545, '2026-03-07', 750, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 580, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 750, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0, 580, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2026-03-07 21:50:08' WHERE storedetailid = '545';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('545', '1', '1', '1', '4862', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '1', '2026-03-07 21:50:08','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2717338',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2716588','750', '0', '1', 'اضافة فاتورة مبيعات', '4862', '2717338', '2026-03-07 21:50:08', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '750', '750', '2026-03-07', '1', '0', '0', '2026-03-07 21:50:08','اضافة فاتورة مبيعات رقم 4862','1','0',null,'0','4862','sellbillController.php?do=showDetail&sellbillid=4862');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10855', '383', '750', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2716338', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10855', '143', '750', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2820385', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '580', '580', '2026-03-07', '1', '0', '0', '2026-03-07 21:50:08','اضافة فاتورة مبيعات رقم 4862 - صرف البضاعة من المخزن','1','0',null,'0','4862','sellbillController.php?do=showDetail&sellbillid=4862');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10856', '402', '580', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2004318.55', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10856', '382', '580', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1139713.05', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10855,0,10856' where sellbillid=4862;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 750, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,580, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 750, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,580, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 750, 580, 580
                    , 580, 580, 580, 580, 580, 580)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+750, netSellCostBuyPrice = netSellCostBuyPrice+580
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+580
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+580
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+580
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+580
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+580
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+580
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+580;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac814b6f285 and sellbillId = 4862 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:20:09";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:50:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:50:09', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:28:05";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:58:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:58:05', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac817209f2d
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 21:50:10', '069ac817209f2d', '1', '0.00', '0', '50', '1', '700.00', '650', '650', '0', '1', '2026-03-07 21:58:06', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','650','0','','0','0','650','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4863', '0', '2026-03-07 21:58:06', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '650', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:50:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 321;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00226', '4863', '1', '226', '1', '450', '450.00', '0', '', '0', '2026-03-07 21:58:06', '226', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','321-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 264.96, meanbuyprice_withDiscount = 264.97
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 264.96
                where sellbilldetailid = 7387;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (226, '2026-03-07', 417.85714285714, 265, 265
                    , 265, 264.96, 264.97, 264.97
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+417.85714285714, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+264.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+264.97
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+264.97
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 417.85714285714, 265, 265
                    , 265, 264.96, 264.97, 264.97
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+417.85714285714, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+264.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+264.97
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+264.97
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '40', userid = '1', storedetaildate = '2026-03-07 21:58:06' WHERE storedetailid = '226';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('226', '1', '1', '1', '4863', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '1', '2026-03-07 21:58:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 566;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00480', '4863', '15', '480', '1', '250', '250.00', '0', '', '0', '2026-03-07 21:58:06', '480', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','566-1,','1','1','0','0','250','250','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 = 7388;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (480, '2026-03-07', 232.14285714286, 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+232.14285714286, 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, '2026-03-07', 232.14285714286, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 175, 175, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+232.14285714286, 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 = '17', userid = '1', storedetaildate = '2026-03-07 21:58:07' WHERE storedetailid = '480';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('480', '1', '1', '1', '4863', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '1', '2026-03-07 21:58:07','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2717988',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2717338','650', '0', '1', 'اضافة فاتورة مبيعات', '4863', '2717988', '2026-03-07 21:58:07', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '700', '700', '2026-03-07', '1', '0', '0', '2026-03-07 21:58:07','اضافة فاتورة مبيعات رقم 4863','1','0',null,'0','4863','sellbillController.php?do=showDetail&sellbillid=4863');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10857', '383', '650', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2716988', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10857', '398', '50', '','0');
UPDATE accountstree SET name = 'خصم مسموح به', customName = 'خصم مسموح به', customNameEn = '', nameEn = '', parent = '158', accountNature = '0', theValue = '52500', theOrder = '0', layingOrder = '51', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-08-08 17:58:26' WHERE id = '398';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10857', '143', '700', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2821085', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '439.96', '439.96', '2026-03-07', '1', '0', '0', '2026-03-07 21:58:07','اضافة فاتورة مبيعات رقم 4863 - صرف البضاعة من المخزن','1','0',null,'0','4863','sellbillController.php?do=showDetail&sellbillid=4863');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10858', '402', '439.96', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2004758.51', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10858', '382', '439.96', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1140153.01', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10857,0,10858' where sellbillid=4863;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 650, 440, 440
                    , 440, 439.96, 439.97, 439.97
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+439.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+439.97
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+439.97
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 650, 440, 440
                    , 440, 439.96, 439.97, 439.97
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+439.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+439.97
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+439.97
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 650, 440, 440
                    , 440, 439.96, 439.97, 439.97, 440, 440)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+650, netSellCostBuyPrice = netSellCostBuyPrice+440
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+440
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+440
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+439.96
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+439.97
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+439.97
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+440
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+440;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac817209f2d and sellbillId = 4863 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:28:08";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:58:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:58:08', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:29:55";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:59:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:59:55', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac8351277c5
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 21:58:09', '069ac8351277c5', '1', '0.00', '0', '0', '1', '900.00', '900', '900', '0', '1', '2026-03-07 21:59:55', '', '1', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4864', '0', '2026-03-07 21:59:55', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '900', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:58:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 643;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('409.93','00521', '4864', '12', '521', '1', '450', '450.00', '0', '', '0', '2026-03-07 21:59:56', '521', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','643-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 409.42, meanbuyprice_withDiscount = 409.79
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 410, lastbuyprice_withDiscountAndTax = 409.42
                where sellbilldetailid = 7389;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (521, '2026-03-07', 450, 410, 410
                    , 410, 409.42, 409.79, 409.8
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+409.42, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+409.79
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+409.8
                            , 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, '2026-03-07', 450, 410, 410
                    , 410, 409.42, 409.79, 409.8
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+409.42, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+409.79
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+409.8
                            , 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 = '40', userid = '1', storedetaildate = '2026-03-07 21:59:56' WHERE storedetailid = '521';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('521', '1', '1', '1', '4864', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '1', '2026-03-07 21:59:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 704;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00572', '4864', '12', '572', '1', '450', '450.00', '0', '', '0', '2026-03-07 21:59:56', '572', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','704-1,','1','1','0','0','450','450','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 = 7390;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (572, '2026-03-07', 450, 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+450, 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, '2026-03-07', 450, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2026-03-07 21:59:56' WHERE storedetailid = '572';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('572', '1', '1', '1', '4864', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '1', '2026-03-07 21:59:56','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2718888',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2717988','900', '0', '1', 'اضافة فاتورة مبيعات', '4864', '2718888', '2026-03-07 21:59:56', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '900', '900', '2026-03-07', '1', '0', '0', '2026-03-07 21:59:56','اضافة فاتورة مبيعات رقم 4864','1','0',null,'0','4864','sellbillController.php?do=showDetail&sellbillid=4864');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10859', '383', '900', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2717888', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10859', '143', '900', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2821985', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '809.42', '809.42', '2026-03-07', '1', '0', '0', '2026-03-07 21:59:56','اضافة فاتورة مبيعات رقم 4864 - صرف البضاعة من المخزن','1','0',null,'0','4864','sellbillController.php?do=showDetail&sellbillid=4864');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10860', '402', '809.42', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2005567.93', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10860', '382', '809.42', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1140962.43', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10859,0,10860' where sellbillid=4864;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 900, 810, 810
                    , 810, 809.42, 809.79, 809.8
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,810, 810, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+810
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+810, sellCostMeanBuyPrice = sellCostMeanBuyPrice+810
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+809.42, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+809.79
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+809.8
                            , 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 (1, '2026-03-07', 900, 810, 810
                    , 810, 809.42, 809.79, 809.8
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,810, 810, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+810
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+810, sellCostMeanBuyPrice = sellCostMeanBuyPrice+810
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+809.42, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+809.79
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+809.8
                            , 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, 900, 810, 810
                    , 810, 809.42, 809.79, 809.8, 810, 810)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+900, netSellCostBuyPrice = netSellCostBuyPrice+810
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+810
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+810
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+809.42
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+809.79
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+809.8
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+810
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+810;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac8351277c5 and sellbillId = 4864 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:29:57";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 21:59:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 21:59:57', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:30:38";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:00:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:00:38', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac83be3a3db
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 21:59:58', '069ac83be3a3db', '1', '0.00', '0', '0', '1', '350.00', '350', '350', '0', '1', '2026-03-07 22:00:38', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','350','0','','0','0','350','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4865', '0', '2026-03-07 22:00:39', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '350', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 21:59:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 693;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00560', '4865', '15', '560', '1', '350', '350.00', '0', '', '0', '2026-03-07 22:00:39', '560', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','693-1,','1','1','0','0','350','350','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 = 7391;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (560, '2026-03-07', 350, 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+350, 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, '2026-03-07', 350, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, 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 = '48', userid = '1', storedetaildate = '2026-03-07 22:00:39' WHERE storedetailid = '560';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('560', '1', '1', '1', '4865', 'اضافة فاتورة مبيعات', 'sellbillController.php', '49', '48', '1', '2026-03-07 22:00:39','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2719238',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2718888','350', '0', '1', 'اضافة فاتورة مبيعات', '4865', '2719238', '2026-03-07 22:00:39', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '350', '350', '2026-03-07', '1', '0', '0', '2026-03-07 22:00:39','اضافة فاتورة مبيعات رقم 4865','1','0',null,'0','4865','sellbillController.php?do=showDetail&sellbillid=4865');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10861', '383', '350', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2718238', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10861', '143', '350', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2822335', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '260', '260', '2026-03-07', '1', '0', '0', '2026-03-07 22:00:39','اضافة فاتورة مبيعات رقم 4865 - صرف البضاعة من المخزن','1','0',null,'0','4865','sellbillController.php?do=showDetail&sellbillid=4865');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10862', '402', '260', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2005827.93', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10862', '382', '260', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1141222.43', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10861,0,10862' where sellbillid=4865;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 350, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+260
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 350, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+260
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 350, 260, 260
                    , 260, 260, 260, 260, 260, 260)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+350, netSellCostBuyPrice = netSellCostBuyPrice+260
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+260
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+260
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+260
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+260
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+260
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+260
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+260;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac83be3a3db and sellbillId = 4865 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:30:40";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:00:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:00:40', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:32:05";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:02:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:02:05', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac83e946120
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:00:41', '069ac83e946120', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2026-03-07 22:02:06', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4866', '0', '2026-03-07 22:02:06', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:00:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 629;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('209.71','00240', '4866', '12', '240', '1', '200', '200.00', '0', '', '0', '2026-03-07 22:02:06', '240', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','629-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 195.88, lastbuyprice_withDiscount = 209.71, meanbuyprice_withDiscount = 195.81
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 226.22, lastbuyprice_withDiscountAndTax = 209.71
                where sellbilldetailid = 7392;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (240, '2026-03-07', 200, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 200, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 22:02:07' WHERE storedetailid = '240';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('240', '1', '1', '1', '4866', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '1', '2026-03-07 22:02:07','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2719438',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2719238','200', '0', '1', 'اضافة فاتورة مبيعات', '4866', '2719438', '2026-03-07 22:02:07', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '200', '200', '2026-03-07', '1', '0', '0', '2026-03-07 22:02:07','اضافة فاتورة مبيعات رقم 4866','1','0',null,'0','4866','sellbillController.php?do=showDetail&sellbillid=4866');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10863', '383', '200', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2718438', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10863', '143', '200', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2822535', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '209.71', '209.71', '2026-03-07', '1', '0', '0', '2026-03-07 22:02:07','اضافة فاتورة مبيعات رقم 4866 - صرف البضاعة من المخزن','1','0',null,'0','4866','sellbillController.php?do=showDetail&sellbillid=4866');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10864', '402', '209.71', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2006037.64', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10864', '382', '209.71', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1141432.14', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10863,0,10864' where sellbillid=4866;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 200, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 200, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 175, 210
                    , 195.88, 209.71, 195.81, 242.13, 210, 226.22)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+175
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+195.88
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+209.71
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+195.81
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+242.13
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+210
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+226.22;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac83e946120 and sellbillId = 4866 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:32:08";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:02:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:02:08', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:39:05";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:09:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:09:05', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac8440d8c3b
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:02:08', '069ac8440d8c3b', '1', '0.00', '0', '0', '1', '250.00', '250', '250', '0', '1', '2026-03-07 22:09:05', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4867', '0', '2026-03-07 22:09:05', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '250', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:02:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 629;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('209.71','00240', '4867', '12', '240', '1', '250', '250.00', '0', '', '0', '2026-03-07 22:09:06', '240', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','629-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 195.88, lastbuyprice_withDiscount = 209.71, meanbuyprice_withDiscount = 195.81
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 226.22, lastbuyprice_withDiscountAndTax = 209.71
                where sellbilldetailid = 7393;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (240, '2026-03-07', 250, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 250, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 22:09:06' WHERE storedetailid = '240';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('240', '1', '1', '1', '4867', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '1', '2026-03-07 22:09:06','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2719688',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2719438','250', '0', '1', 'اضافة فاتورة مبيعات', '4867', '2719688', '2026-03-07 22:09:06', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '250', '250', '2026-03-07', '1', '0', '0', '2026-03-07 22:09:06','اضافة فاتورة مبيعات رقم 4867','1','0',null,'0','4867','sellbillController.php?do=showDetail&sellbillid=4867');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10865', '383', '250', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2718688', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10865', '143', '250', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2822785', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '209.71', '209.71', '2026-03-07', '1', '0', '0', '2026-03-07 22:09:06','اضافة فاتورة مبيعات رقم 4867 - صرف البضاعة من المخزن','1','0',null,'0','4867','sellbillController.php?do=showDetail&sellbillid=4867');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10866', '402', '209.71', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2006247.35', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10866', '382', '209.71', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1141641.85', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10865,0,10866' where sellbillid=4867;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 250, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 250, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 175, 210
                    , 195.88, 209.71, 195.81, 242.13, 210, 226.22)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+250, netSellCostBuyPrice = netSellCostBuyPrice+175
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+195.88
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+209.71
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+195.81
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+242.13
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+210
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+226.22;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac8440d8c3b and sellbillId = 4867 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:39:07";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:09:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:09:07', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:39:10";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:09:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:09:11', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:39:18";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:09:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:09:18', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac85e7b89f4
-- ----------------------------------------------------------------------------------------------------

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,returnsellbilltypeclientid) VALUES ('2026-03-07 22:09:11', '069ac85e7b89f4', '1', '0.00', '0', '0', '1', '250', '250', '-250', '0', '1', '2026-03-07 22:09:19', '', '1', '0', 'نقدي','1', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-250','0','0','0','0','0','0','0','0','-1','0','0','1','','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, 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','اضافة فاتورة مردوات مبيعات','506', '0', '2026-03-07 22:09:19', '1', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '250', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:09:11','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('175.00', '00240', '506', '12', '240', '1', '250', '250', '0', '', '0', '0', '240', '0.00', '-1','1','0','','','0','0','0','0','0','0','1','1','','0','0','250','250','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 195.88, lastbuyprice_withDiscount = 209.71, meanbuyprice_withDiscount = 195.81
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 226.22, lastbuyprice_withDiscountAndTax = 209.71
                where returnsellbilldetailid = 570;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (240, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 175, 210, 195.88
                    , 209.71, 195.81, 242.13, 0, 1, 0, 0, 210, 226.22)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+250, returnSellCostBuyPrice = returnSellCostBuyPrice+175, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195.88, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+209.71
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195.81
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+242.13
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+210
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+226.22
                        , 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, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 175, 210, 195.88
                    , 209.71, 195.81, 242.13, 0, 0, 210, 226.22)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+250, returnSellCostBuyPrice = returnSellCostBuyPrice+175, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195.88, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+209.71
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195.81
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+242.13
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+210
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+226.22;
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2026-03-07 22:09:19' WHERE storedetailid = '240';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('240', '1', '1', '0', '506', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '22', '23', '1', '2026-03-07 22:09:19','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2719438',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2719688','-250', '1', '1', 'اضافة فاتورة مردوات مبيعات', '506', '2719438', '2026-03-07 22:09:19', '1',  'returnsellbillController.php','1','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '250', '250', '2026-03-07', '1', '0', '0', '2026-03-07 22:09:19','اضافة فاتورة مردود مبيعات رقم 506','1','0',null,'0','506','returnsellbillController.php?do=showDetail&returnsellbillid=506');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10867', '143', '250', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2822535', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10867', '383', '250', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2718438', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '209.71', '209.71', '2026-03-07', '1', '0', '0', '2026-03-07 22:09:19','اضافة فاتورة مردود مبيعات رقم 506 - صرف البضاعة من المخزن','1','0',null,'0','506','returnsellbillController.php?do=showDetail&returnsellbillid=506');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10868', '382', '209.71', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1141432.14', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10868', '402', '209.71', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2006037.64', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
update returnsellbill set dailyentryid='10867,0,10868' where returnsellbillid=506;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 175, 210, 195.88
                    , 209.71, 195.81, 242.13 ,0, 0, 210, 226.22)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+250, returnSellCostBuyPrice = returnSellCostBuyPrice+175, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195.88, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+209.71
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195.81
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+242.13
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+210
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+226.22;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 175, 210, 195.88
                    , 209.71, 195.81, 242.13 ,0, 0, 210, 226.22)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+250, returnSellCostBuyPrice = returnSellCostBuyPrice+175, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195.88, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+209.71
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195.81
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+242.13
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+210
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+226.22;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -250, -175, -210
                    , -195.88, -209.71, -195.81, -242.13, -210, -226.22)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-250, netSellCostBuyPrice = netSellCostBuyPrice+-175
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-195.88
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-209.71
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-195.81
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-242.13
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-210
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-226.22;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac85e7b89f4 and sellbillId = 506 and returnsellbillId = 506
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:39:20";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:09:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:09:20', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:39:25";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:09:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:09:25', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:39:44";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:09:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:09:44', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac85f60d26a
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:09:26', '069ac85f60d26a', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2026-03-07 22:09:44', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4868', '0', '2026-03-07 22:09:44', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:09:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 629;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('209.71','00240', '4868', '12', '240', '1', '200', '200.00', '0', '', '0', '2026-03-07 22:09:44', '240', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','629-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 195.88, lastbuyprice_withDiscount = 209.71, meanbuyprice_withDiscount = 195.81
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 226.22, lastbuyprice_withDiscountAndTax = 209.71
                where sellbilldetailid = 7394;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (240, '2026-03-07', 200, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 200, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 22:09:45' WHERE storedetailid = '240';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('240', '1', '1', '1', '4868', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '1', '2026-03-07 22:09:45','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2719638',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2719438','200', '0', '1', 'اضافة فاتورة مبيعات', '4868', '2719638', '2026-03-07 22:09:45', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '200', '200', '2026-03-07', '1', '0', '0', '2026-03-07 22:09:45','اضافة فاتورة مبيعات رقم 4868','1','0',null,'0','4868','sellbillController.php?do=showDetail&sellbillid=4868');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10869', '383', '200', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2718638', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10869', '143', '200', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2822735', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '209.71', '209.71', '2026-03-07', '1', '0', '0', '2026-03-07 22:09:45','اضافة فاتورة مبيعات رقم 4868 - صرف البضاعة من المخزن','1','0',null,'0','4868','sellbillController.php?do=showDetail&sellbillid=4868');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10870', '402', '209.71', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2006247.35', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10870', '382', '209.71', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1141641.85', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10869,0,10870' where sellbillid=4868;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 200, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 200, 175, 210
                    , 195.88, 209.71, 195.81, 242.13
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,210, 226.22, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.88
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+209.71, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.81
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+242.13
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+226.22
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 175, 210
                    , 195.88, 209.71, 195.81, 242.13, 210, 226.22)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+175
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+195.88
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+209.71
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+195.81
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+242.13
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+210
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+226.22;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac85f60d26a and sellbillId = 4868 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:39:46";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:09:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:09:46', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:41:17";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:11:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:11:17', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac860acb9bc
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:09:46', '069ac860acb9bc', '1', '0.00', '0', '0', '1', '800.00', '800', '800', '0', '1', '2026-03-07 22:11:18', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','800','0','','0','0','800','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4869', '0', '2026-03-07 22:11:18', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:09:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 632;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00489', '4869', '15', '489', '1', '250', '250.00', '0', '', '0', '2026-03-07 22:11:18', '489', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','632-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 = 209.84
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where sellbilldetailid = 7395;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (489, '2026-03-07', 250, 210, 210
                    , 210, 210, 209.84, 209.87
                    , 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+209.84
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+209.87
                            , 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, '2026-03-07', 250, 210, 210
                    , 210, 210, 209.84, 209.87
                    , 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+209.84
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+209.87
                            , 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 = '61', userid = '1', storedetaildate = '2026-03-07 22:11:18' WHERE storedetailid = '489';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('489', '1', '1', '1', '4869', 'اضافة فاتورة مبيعات', 'sellbillController.php', '62', '61', '1', '2026-03-07 22:11: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 ('375','00420', '4869', '15', '420', '1', '300', '300.00', '0', '', '0', '2026-03-07 22:11:18', '420', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 374.25, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 374.25
        , lastbuyprice_withTax = 375, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 375
                where sellbilldetailid = 7396;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (420, '2026-03-07', 300, 375, 375
                    , 374.25, 375, 374.25, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+374.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+374.25
                            , 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, '2026-03-07', 300, 375, 375
                    , 374.25, 375, 374.25, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+374.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+374.25
                            , 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 = '-15', userid = '1', storedetaildate = '2026-03-07 22:11:19' WHERE storedetailid = '420';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('420', '1', '1', '1', '4869', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-14', '-15', '1', '2026-03-07 22:11:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 660;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00263', '4869', '1', '263', '1', '250', '250.00', '0', '', '0', '2026-03-07 22:11:19', '263', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','660-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.08
        , lastbuyprice_withTax = 195, meanbuyprice_withTax = 195, lastbuyprice_withDiscountAndTax = 195
                where sellbilldetailid = 7397;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (263, '2026-03-07', 250, 195, 195
                    , 195, 195, 195.08, 194.98
                    , 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.08
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+194.98
                            , 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, '2026-03-07', 250, 195, 195
                    , 195, 195, 195.08, 194.98
                    , 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.08
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+194.98
                            , 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 = '5', userid = '1', storedetaildate = '2026-03-07 22:11:19' WHERE storedetailid = '263';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('263', '1', '1', '1', '4869', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '1', '2026-03-07 22:11:19','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2720438',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2719638','800', '0', '1', 'اضافة فاتورة مبيعات', '4869', '2720438', '2026-03-07 22:11:19', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '800', '800', '2026-03-07', '1', '0', '0', '2026-03-07 22:11:19','اضافة فاتورة مبيعات رقم 4869','1','0',null,'0','4869','sellbillController.php?do=showDetail&sellbillid=4869');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10871', '383', '800', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2719438', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10871', '143', '800', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2823535', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '780', '780', '2026-03-07', '1', '0', '0', '2026-03-07 22:11:19','اضافة فاتورة مبيعات رقم 4869 - صرف البضاعة من المخزن','1','0',null,'0','4869','sellbillController.php?do=showDetail&sellbillid=4869');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10872', '402', '780', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2007027.35', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10872', '382', '780', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1142421.85', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10871,0,10872' where sellbillid=4869;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 800, 780, 780
                    , 779.25, 780, 779.17, 779.85
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,780, 780, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+779.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+779.17
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+779.85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+780
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+780
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 800, 780, 780
                    , 779.25, 780, 779.17, 779.85
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,780, 780, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+779.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+779.17
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+779.85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+780
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+780
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 780, 780
                    , 779.25, 780, 779.17, 779.85, 780, 780)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+800, netSellCostBuyPrice = netSellCostBuyPrice+780
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+780
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+779.25
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+780
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+779.17
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+779.85
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+780
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+780;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac860acb9bc and sellbillId = 4869 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:41:20";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:11:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:11:20', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:50:07";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:20:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:20:07', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac86690dd6b
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:11:21', '069ac86690dd6b', '1', '0.00', '0', '50', '1', '1250.00', '1200', '1200', '0', '1', '2026-03-07 22:20:08', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','1200','0','','0','0','1200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4870', '0', '2026-03-07 22:20:08', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1200', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:11:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 658;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00536', '4870', '23', '536', '1', '500', '500.00', '0', '', '0', '2026-03-07 22:20:08', '536', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','658-1,','1','1','0','0','500','500','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 = 7398;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (536, '2026-03-07', 480, 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+480, 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, '2026-03-07', 480, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, 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 = '3', userid = '1', storedetaildate = '2026-03-07 22:20:08' WHERE storedetailid = '536';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('536', '1', '1', '1', '4870', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '1', '2026-03-07 22:20:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 670;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('580','00545', '4870', '6', '545', '1', '750', '750.00', '0', '', '0', '2026-03-07 22:20:08', '545', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','670-1,','1','1','0','0','750','750','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 580.00 , meanbuyprice = 580.00, lastbuyprice_withDiscount = 580.00, meanbuyprice_withDiscount = 580.00
        , lastbuyprice_withTax = 580, meanbuyprice_withTax = 580, lastbuyprice_withDiscountAndTax = 580
                where sellbilldetailid = 7399;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (545, '2026-03-07', 720, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 580, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 720, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0, 580, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2026-03-07 22:20:08' WHERE storedetailid = '545';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('545', '1', '1', '1', '4870', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '1', '2026-03-07 22:20:08','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2721638',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2720438','1200', '0', '1', 'اضافة فاتورة مبيعات', '4870', '2721638', '2026-03-07 22:20:08', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1250', '1250', '2026-03-07', '1', '0', '0', '2026-03-07 22:20:08','اضافة فاتورة مبيعات رقم 4870','1','0',null,'0','4870','sellbillController.php?do=showDetail&sellbillid=4870');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10873', '383', '1200', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2720638', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10873', '398', '50', '','0');
UPDATE accountstree SET name = 'خصم مسموح به', customName = 'خصم مسموح به', customNameEn = '', nameEn = '', parent = '158', accountNature = '0', theValue = '52550', theOrder = '0', layingOrder = '51', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-08-08 17:58:26' WHERE id = '398';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10873', '143', '1250', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2824785', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '900', '900', '2026-03-07', '1', '0', '0', '2026-03-07 22:20:08','اضافة فاتورة مبيعات رقم 4870 - صرف البضاعة من المخزن','1','0',null,'0','4870','sellbillController.php?do=showDetail&sellbillid=4870');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10874', '402', '900', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2007927.35', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10874', '382', '900', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1143321.85', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10873,0,10874' where sellbillid=4870;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 1200, 900, 900
                    , 900, 900, 900, 900
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,900, 900, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+900
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+900
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+900
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 1200, 900, 900
                    , 900, 900, 900, 900
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,900, 900, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+900
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+900
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+900
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1200, 900, 900
                    , 900, 900, 900, 900, 900, 900)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1200, netSellCostBuyPrice = netSellCostBuyPrice+900
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+900
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+900
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+900
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+900
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+900
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+900
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+900;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac86690dd6b and sellbillId = 4870 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:50:09";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:20:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:20:09', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:52:28";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:22:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:22:28', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac887a0e435
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:20:10', '069ac887a0e435', '1', '0.00', '0', '0', '1', '950.00', '950', '950', '0', '1', '2026-03-07 22:22:28', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','950','0','','0','0','950','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4871', '0', '2026-03-07 22:22:29', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '950', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:20:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 605;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('415','00505', '4871', '1', '505', '1', '650', '650.00', '0', '', '0', '2026-03-07 22:22:29', '505', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','605-1,','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 415.00 , meanbuyprice = 415.00, lastbuyprice_withDiscount = 415.00, meanbuyprice_withDiscount = 415.00
        , lastbuyprice_withTax = 415, meanbuyprice_withTax = 415, lastbuyprice_withDiscountAndTax = 415
                where sellbilldetailid = 7400;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (505, '2026-03-07', 650, 415, 415
                    , 415, 415, 415, 415
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 415, 415, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+415, sellCostMeanBuyPrice = sellCostMeanBuyPrice+415
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+415, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+415
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+415
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+415
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+415
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 650, 415, 415
                    , 415, 415, 415, 415
                    , 0, 0, 0, 0
                    , 0, 0, 0, 415, 415, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+415, sellCostMeanBuyPrice = sellCostMeanBuyPrice+415
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+415, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+415
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+415
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+415
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+415
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 22:22:29' WHERE storedetailid = '505';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('505', '1', '1', '1', '4871', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '1', '2026-03-07 22:22:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 638;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('239.96','00520', '4871', '15', '520', '1', '300', '300.00', '0', '', '0', '2026-03-07 22:22:29', '520', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','638-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 = 239.96, meanbuyprice_withDiscount = 239.96
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 239.96
                where sellbilldetailid = 7401;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (520, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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 = '75', userid = '1', storedetaildate = '2026-03-07 22:22:29' WHERE storedetailid = '520';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('520', '1', '1', '1', '4871', 'اضافة فاتورة مبيعات', 'sellbillController.php', '76', '75', '1', '2026-03-07 22:22:29','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2722588',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2721638','950', '0', '1', 'اضافة فاتورة مبيعات', '4871', '2722588', '2026-03-07 22:22:29', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '950', '950', '2026-03-07', '1', '0', '0', '2026-03-07 22:22:29','اضافة فاتورة مبيعات رقم 4871','1','0',null,'0','4871','sellbillController.php?do=showDetail&sellbillid=4871');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10875', '383', '950', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2721588', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10875', '143', '950', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2825735', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '654.96', '654.96', '2026-03-07', '1', '0', '0', '2026-03-07 22:22:29','اضافة فاتورة مبيعات رقم 4871 - صرف البضاعة من المخزن','1','0',null,'0','4871','sellbillController.php?do=showDetail&sellbillid=4871');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10876', '402', '654.96', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2008582.31', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10876', '382', '654.96', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1143976.81', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10875,0,10876' where sellbillid=4871;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 950, 655, 655
                    , 655, 654.96, 654.96, 654.96
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,655, 655, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+655
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+655, sellCostMeanBuyPrice = sellCostMeanBuyPrice+655
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+654.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+654.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+654.96
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+655
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+655
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 950, 655, 655
                    , 655, 654.96, 654.96, 654.96
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,655, 655, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+655
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+655, sellCostMeanBuyPrice = sellCostMeanBuyPrice+655
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+654.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+654.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+654.96
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+655
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+655
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 950, 655, 655
                    , 655, 654.96, 654.96, 654.96, 655, 655)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+950, netSellCostBuyPrice = netSellCostBuyPrice+655
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+655
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+655
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+654.96
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+654.96
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+654.96
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+655
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+655;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac887a0e435 and sellbillId = 4871 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:52:30";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:22:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:22:30', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:59:32";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:29:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:29:33', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac6ce9797e1
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 20:22:33', '069ac6ce9797e1', '1', '0.00', '0', '50', '1', '550.00', '500', '500', '0', '1', '2026-03-07 22:29:33', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4872', '0', '2026-03-07 22:29:33', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 20:22:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 654;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00532', '4872', '24', '532', '1', '550', '550.00', '0', '', '0', '2026-03-07 22:29:33', '532', '0.00', '0', '1','0.00','','','0','0','0','0','0','0','0','0','','654-1,','1','1','0','0','550','550','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 = 7402;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (532, '2026-03-07', 500, 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+500, 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, '2026-03-07', 500, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2026-03-07 22:29:34' WHERE storedetailid = '532';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('532', '1', '1', '1', '4872', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '1', '2026-03-07 22:29:34','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2723088',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2722588','500', '0', '1', 'اضافة فاتورة مبيعات', '4872', '2723088', '2026-03-07 22:29:34', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '550', '550', '2026-03-07', '1', '0', '0', '2026-03-07 22:29:34','اضافة فاتورة مبيعات رقم 4872','1','0',null,'0','4872','sellbillController.php?do=showDetail&sellbillid=4872');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10877', '383', '500', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2722088', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10877', '398', '50', '','0');
UPDATE accountstree SET name = 'خصم مسموح به', customName = 'خصم مسموح به', customNameEn = '', nameEn = '', parent = '158', accountNature = '0', theValue = '52600', theOrder = '0', layingOrder = '51', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-08-08 17:58:26' WHERE id = '398';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10877', '143', '550', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2826285', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '350', '350', '2026-03-07', '1', '0', '0', '2026-03-07 22:29:34','اضافة فاتورة مبيعات رقم 4872 - صرف البضاعة من المخزن','1','0',null,'0','4872','sellbillController.php?do=showDetail&sellbillid=4872');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10878', '402', '350', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2008932.31', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10878', '382', '350', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1144326.81', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10877,0,10878' where sellbillid=4872;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 500, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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, '2026-03-07', 500, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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, 500, 350, 350
                    , 350, 350, 350, 350, 350, 350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, 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 069ac6ce9797e1 and sellbillId = 4872 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 18:59:35";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:29:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:29:35', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:01:37";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:31:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:31:37', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac890755e69
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:22:31', '069ac890755e69', '1', '0.00', '0', '0', '1', '1450.00', '1450', '1450', '0', '1', '2026-03-07 22:31:38', '', '1', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1450','0','','0','0','1450','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4873', '0', '2026-03-07 22:31:38', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1450', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:22:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 344;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('540','00241', '4873', '12', '241', '1', '450', '450.00', '0', '', '0', '2026-03-07 22:31:38', '241', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','344-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 540.00 , meanbuyprice = 540.00, lastbuyprice_withDiscount = 540.00, meanbuyprice_withDiscount = 540.00
        , lastbuyprice_withTax = 540, meanbuyprice_withTax = 540, lastbuyprice_withDiscountAndTax = 540
                where sellbilldetailid = 7403;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (241, '2026-03-07', 450, 540, 540
                    , 540, 540, 540, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 540, 540, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+540
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+540
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+540
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+540
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 450, 540, 540
                    , 540, 540, 540, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 540, 540, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+540
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+540
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+540
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+540
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2026-03-07 22:31:39' WHERE storedetailid = '241';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('241', '1', '1', '1', '4873', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '1', '2026-03-07 22:31:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 141;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('333.35','00124', '4873', '1', '124', '1', '500', '500.00', '0', '', '0', '2026-03-07 22:31:39', '124', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','141-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 335.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 335.00, meanbuyprice_withDiscount = 334.08
        , lastbuyprice_withTax = 335, meanbuyprice_withTax = 335, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 7404;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (124, '2026-03-07', 500, 335, 335
                    , 335, 335, 334.08, 334.1
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 335, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+334.08
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+334.1
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , 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
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 500, 335, 335
                    , 335, 335, 334.08, 334.1
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 335, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+334.08
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+334.1
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , 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;
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2026-03-07 22:31:39' WHERE storedetailid = '124';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '1', '1', '1', '4873', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '1', '2026-03-07 22:31:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 676;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('325','00408', '4873', '2', '408', '1', '500', '500.00', '0', '', '0', '2026-03-07 22:31:39', '408', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','676-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 325.00 , meanbuyprice = 325.78, lastbuyprice_withDiscount = 325.00, meanbuyprice_withDiscount = 325.77
        , lastbuyprice_withTax = 325, meanbuyprice_withTax = 326.94, lastbuyprice_withDiscountAndTax = 325
                where sellbilldetailid = 7405;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (408, '2026-03-07', 500, 325, 325
                    , 325.78, 325, 325.77, 326.7
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 325, 326.94, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+325
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+325, sellCostMeanBuyPrice = sellCostMeanBuyPrice+325.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+325, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+325.77
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+326.7
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+325
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+326.94
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 500, 325, 325
                    , 325.78, 325, 325.77, 326.7
                    , 0, 0, 0, 0
                    , 0, 0, 0, 325, 326.94, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+325
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+325, sellCostMeanBuyPrice = sellCostMeanBuyPrice+325.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+325, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+325.77
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+326.7
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+325
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+326.94
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '1', storedetaildate = '2026-03-07 22:31:39' WHERE storedetailid = '408';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('408', '1', '1', '1', '4873', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '1', '2026-03-07 22:31:39','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2724538',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2723088','1450', '0', '1', 'اضافة فاتورة مبيعات', '4873', '2724538', '2026-03-07 22:31:39', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1450', '1450', '2026-03-07', '1', '0', '0', '2026-03-07 22:31:39','اضافة فاتورة مبيعات رقم 4873','1','0',null,'0','4873','sellbillController.php?do=showDetail&sellbillid=4873');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10879', '383', '1450', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2723538', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10879', '143', '1450', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2827735', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1200', '1200', '2026-03-07', '1', '0', '0', '2026-03-07 22:31:39','اضافة فاتورة مبيعات رقم 4873 - صرف البضاعة من المخزن','1','0',null,'0','4873','sellbillController.php?do=showDetail&sellbillid=4873');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10880', '402', '1200', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2010132.31', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10880', '382', '1200', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1145526.81', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10879,0,10880' where sellbillid=4873;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 1450, 1200, 1200
                    , 1200.78, 1200, 1199.85, 1200.8
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1200, 1201.94, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1450, sellCostBuyPrice =sellCostBuyPrice+1200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1200.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1199.85
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1200.8
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1201.94
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 1450, 1200, 1200
                    , 1200.78, 1200, 1199.85, 1200.8
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1200, 1201.94, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1450, sellCostBuyPrice =sellCostBuyPrice+1200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1200.78
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1199.85
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1200.8
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1201.94
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1450, 1200, 1200
                    , 1200.78, 1200, 1199.85, 1200.8, 1200, 1201.94)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1450, netSellCostBuyPrice = netSellCostBuyPrice+1200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1200.78
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1199.85
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1200.8
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1200
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1201.94;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac890755e69 and sellbillId = 4873 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:01:40";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:31:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:31:40', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:08:49";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:38:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:38:49', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac8b2d30b3b
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:31:41', '069ac8b2d30b3b', '1', '0.00', '0', '0', '1', '450.00', '450', '450', '0', '1', '2026-03-07 22:38:49', '', '1', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4874', '0', '2026-03-07 22:38:49', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '450', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:31:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 704;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00572', '4874', '12', '572', '1', '450', '450.00', '0', '', '0', '2026-03-07 22:38:50', '572', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','704-1,','1','1','0','0','450','450','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 = 7406;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (572, '2026-03-07', 450, 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+450, 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, '2026-03-07', 450, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2026-03-07 22:38:50' WHERE storedetailid = '572';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('572', '1', '1', '1', '4874', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '1', '2026-03-07 22:38:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2724988',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2724538','450', '0', '1', 'اضافة فاتورة مبيعات', '4874', '2724988', '2026-03-07 22:38:50', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '450', '450', '2026-03-07', '1', '0', '0', '2026-03-07 22:38:50','اضافة فاتورة مبيعات رقم 4874','1','0',null,'0','4874','sellbillController.php?do=showDetail&sellbillid=4874');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10881', '383', '450', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2723988', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10881', '143', '450', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2828185', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '400', '400', '2026-03-07', '1', '0', '0', '2026-03-07 22:38:50','اضافة فاتورة مبيعات رقم 4874 - صرف البضاعة من المخزن','1','0',null,'0','4874','sellbillController.php?do=showDetail&sellbillid=4874');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10882', '402', '400', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2010532.31', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10882', '382', '400', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1145926.81', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10881,0,10882' where sellbillid=4874;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 450, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 450, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+400
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 450, 400, 400
                    , 400, 400, 400, 400, 400, 400)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+450, netSellCostBuyPrice = netSellCostBuyPrice+400
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+400
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+400
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+400
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+400
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+400
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+400
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+400;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac8b2d30b3b and sellbillId = 4874 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:08:51";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:38:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:38:51', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:08:58";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:38:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:38:58', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:09:07";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:39:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:39:07', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac8ce2edf05
-- ----------------------------------------------------------------------------------------------------

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,returnsellbilltypeclientid) VALUES ('2026-03-07 22:38:59', '069ac8ce2edf05', '1', '0.00', '0', '0', '1', '250', '250', '-250', '0', '1', '2026-03-07 22:39:08', '', '1', '0', 'نقدي','1', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-250','0','0','0','0','0','0','0','0','-1','0','0','1','','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, 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','اضافة فاتورة مردوات مبيعات','507', '0', '2026-03-07 22:39:08', '1', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '250', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:38:59','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 ('195.00', '00263', '507', '1', '263', '1', '250', '250', '0', '', '0', '0', '263', '0.00', '-1','1','0','','','0','0','0','0','0','0','1','1','','0','0','250','250','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.08
        , lastbuyprice_withTax = 195, meanbuyprice_withTax = 195, lastbuyprice_withDiscountAndTax = 195
                where returnsellbilldetailid = 571;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (263, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 195, 195, 195
                    , 195, 195.08, 194.98, 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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195.08
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+194.98
                            , 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, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 195, 195, 195
                    , 195, 195.08, 194.98, 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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195.08
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+194.98
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+195
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+195;
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2026-03-07 22:39:08' WHERE storedetailid = '263';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('263', '1', '1', '0', '507', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '5', '6', '1', '2026-03-07 22:39:08','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2724738',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2724988','-250', '1', '1', 'اضافة فاتورة مردوات مبيعات', '507', '2724738', '2026-03-07 22:39:08', '1',  'returnsellbillController.php','1','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '250', '250', '2026-03-07', '1', '0', '0', '2026-03-07 22:39:08','اضافة فاتورة مردود مبيعات رقم 507','1','0',null,'0','507','returnsellbillController.php?do=showDetail&returnsellbillid=507');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10883', '143', '250', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2827935', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10883', '383', '250', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2723738', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '195', '195', '2026-03-07', '1', '0', '0', '2026-03-07 22:39:08','اضافة فاتورة مردود مبيعات رقم 507 - صرف البضاعة من المخزن','1','0',null,'0','507','returnsellbillController.php?do=showDetail&returnsellbillid=507');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10884', '382', '195', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1145731.81', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10884', '402', '195', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2010337.31', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
update returnsellbill set dailyentryid='10883,0,10884' where returnsellbillid=507;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 195, 195, 195
                    , 195, 195.08, 194.98 ,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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195.08
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+194.98
                            , 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 (1, '2026-03-07', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 195, 195, 195
                    , 195, 195.08, 194.98 ,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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195.08
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+194.98
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+195
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+195;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -250, -195, -195
                    , -195, -195, -195.08, -194.98, -195, -195)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-250, netSellCostBuyPrice = netSellCostBuyPrice+-195
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-195
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-195
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-195
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-195.08
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-194.98
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-195
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-195;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac8ce2edf05 and sellbillId = 507 and returnsellbillId = 507
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:09:09";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:39:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:39:09', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:09:13";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:39:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:39:13', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:10:05";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:40:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:40:05', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac8cf1da3a7
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:39:13', '069ac8cf1da3a7', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2026-03-07 22:40:06', '', '1', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4875', '0', '2026-03-07 22:40:06', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:39: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 ('375','00420', '4875', '15', '420', '1', '300', '300.00', '0', '', '0', '2026-03-07 22:40:06', '420', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 374.25, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 374.25
        , lastbuyprice_withTax = 375, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 375
                where sellbilldetailid = 7407;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (420, '2026-03-07', 300, 375, 375
                    , 374.25, 375, 374.25, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+374.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+374.25
                            , 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, '2026-03-07', 300, 375, 375
                    , 374.25, 375, 374.25, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+374.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+374.25
                            , 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 = '1', storedetaildate = '2026-03-07 22:40:06' WHERE storedetailid = '420';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('420', '1', '1', '1', '4875', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-15', '-16', '1', '2026-03-07 22:40:06','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2725038',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2724738','300', '0', '1', 'اضافة فاتورة مبيعات', '4875', '2725038', '2026-03-07 22:40:06', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '300', '300', '2026-03-07', '1', '0', '0', '2026-03-07 22:40:06','اضافة فاتورة مبيعات رقم 4875','1','0',null,'0','4875','sellbillController.php?do=showDetail&sellbillid=4875');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10885', '383', '300', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2724038', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10885', '143', '300', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2828235', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '375', '375', '2026-03-07', '1', '0', '0', '2026-03-07 22:40:06','اضافة فاتورة مبيعات رقم 4875 - صرف البضاعة من المخزن','1','0',null,'0','4875','sellbillController.php?do=showDetail&sellbillid=4875');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10886', '402', '375', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2010712.31', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10886', '382', '375', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1146106.81', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10885,0,10886' where sellbillid=4875;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 300, 375, 375
                    , 374.25, 375, 374.25, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+374.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+374.25
                            , 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, '2026-03-07', 300, 375, 375
                    , 374.25, 375, 374.25, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+374.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+374.25
                            , 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, 300, 375, 375
                    , 374.25, 375, 374.25, 375, 375, 375)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+375
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+375
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+374.25
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+375
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+374.25
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+375
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+375
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+375;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac8cf1da3a7 and sellbillId = 4875 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:10:07";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:40:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:40:07', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:15:38";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:45:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:45:38', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac8d2895abf
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:40:08', '069ac8d2895abf', '1', '0.00', '0', '0', '1', '750.00', '750', '750', '0', '1', '2026-03-07 22:45:38', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','750','0','','0','0','750','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4876', '0', '2026-03-07 22:45:39', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '750', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:40:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 339;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('700','00236', '4876', '6', '236', '1', '750', '750.00', '0', '', '0', '2026-03-07 22:45:39', '236', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','339-1,','1','1','0','0','750','750','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 700.00 , meanbuyprice = 700.00, lastbuyprice_withDiscount = 700.00, meanbuyprice_withDiscount = 700.00
        , lastbuyprice_withTax = 700, meanbuyprice_withTax = 700, lastbuyprice_withDiscountAndTax = 700
                where sellbilldetailid = 7408;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (236, '2026-03-07', 750, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 700, 700, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+700
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 750, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 700, 700, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+700
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2026-03-07 22:45:39' WHERE storedetailid = '236';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('236', '1', '1', '1', '4876', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '1', '2026-03-07 22:45:39','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2725788',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2725038','750', '0', '1', 'اضافة فاتورة مبيعات', '4876', '2725788', '2026-03-07 22:45:39', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '750', '750', '2026-03-07', '1', '0', '0', '2026-03-07 22:45:39','اضافة فاتورة مبيعات رقم 4876','1','0',null,'0','4876','sellbillController.php?do=showDetail&sellbillid=4876');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10887', '383', '750', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2724788', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10887', '143', '750', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2828985', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '700', '700', '2026-03-07', '1', '0', '0', '2026-03-07 22:45:39','اضافة فاتورة مبيعات رقم 4876 - صرف البضاعة من المخزن','1','0',null,'0','4876','sellbillController.php?do=showDetail&sellbillid=4876');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10888', '402', '700', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2011412.31', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10888', '382', '700', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1146806.81', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10887,0,10888' where sellbillid=4876;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 750, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,700, 700, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+700
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 750, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,700, 700, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+700
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 750, 700, 700
                    , 700, 700, 700, 700, 700, 700)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+750, netSellCostBuyPrice = netSellCostBuyPrice+700
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+700
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+700
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+700
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+700
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+700
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+700
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+700;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac8d2895abf and sellbillId = 4876 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:15:40";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:45:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:45:40', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:20:58";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:50:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:50:58', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac8e75053e6
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:45:41', '069ac8e75053e6', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2026-03-07 22:50:58', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4877', '0', '2026-03-07 22:50:58', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:45:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 685;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('90','00555', '4877', '16', '555', '1', '200', '200.00', '0', '', '0', '2026-03-07 22:50:59', '555', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','685-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 90.00 , meanbuyprice = 90.00, lastbuyprice_withDiscount = 90.00, meanbuyprice_withDiscount = 90.00
        , lastbuyprice_withTax = 90, meanbuyprice_withTax = 90, lastbuyprice_withDiscountAndTax = 90
                where sellbilldetailid = 7409;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (555, '2026-03-07', 200, 90, 90
                    , 90, 90, 90, 90
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 90, 90, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+90
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+90, sellCostMeanBuyPrice = sellCostMeanBuyPrice+90
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+90, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+90
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+90
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+90
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+90
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 200, 90, 90
                    , 90, 90, 90, 90
                    , 0, 0, 0, 0
                    , 0, 0, 0, 90, 90, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+90
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+90, sellCostMeanBuyPrice = sellCostMeanBuyPrice+90
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+90, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+90
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+90
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+90
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+90
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2026-03-07 22:50:59' WHERE storedetailid = '555';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('555', '1', '1', '1', '4877', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '1', '2026-03-07 22:50:59','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2725988',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2725788','200', '0', '1', 'اضافة فاتورة مبيعات', '4877', '2725988', '2026-03-07 22:50:59', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '200', '200', '2026-03-07', '1', '0', '0', '2026-03-07 22:50:59','اضافة فاتورة مبيعات رقم 4877','1','0',null,'0','4877','sellbillController.php?do=showDetail&sellbillid=4877');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10889', '383', '200', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2724988', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10889', '143', '200', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2829185', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '90', '90', '2026-03-07', '1', '0', '0', '2026-03-07 22:50:59','اضافة فاتورة مبيعات رقم 4877 - صرف البضاعة من المخزن','1','0',null,'0','4877','sellbillController.php?do=showDetail&sellbillid=4877');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10890', '402', '90', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2011502.31', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10890', '382', '90', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1146896.81', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10889,0,10890' where sellbillid=4877;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 200, 90, 90
                    , 90, 90, 90, 90
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,90, 90, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+90
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+90, sellCostMeanBuyPrice = sellCostMeanBuyPrice+90
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+90, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+90
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+90
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+90
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+90
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 200, 90, 90
                    , 90, 90, 90, 90
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,90, 90, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+90
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+90, sellCostMeanBuyPrice = sellCostMeanBuyPrice+90
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+90, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+90
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+90
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+90
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+90
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 90, 90
                    , 90, 90, 90, 90, 90, 90)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+90
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+90
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+90
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+90
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+90
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+90
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+90
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+90;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac8e75053e6 and sellbillId = 4877 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:21:00";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 22:51:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 22:51:00', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:32:10";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:02:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:02:10', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac8fb5165c1
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 22:51:01', '069ac8fb5165c1', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2026-03-07 23:02:10', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4878', '0', '2026-03-07 23:02:11', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 22:51:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 569;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00248', '4878', '13', '248', '2', '100', '200.00', '0', '', '0', '2026-03-07 23:02:11', '248', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','569-2,','1','1','0','0','100','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 85.00 , meanbuyprice = 85.40, lastbuyprice_withDiscount = 85.00, meanbuyprice_withDiscount = 85.40
        , lastbuyprice_withTax = 85, meanbuyprice_withTax = 86.26, lastbuyprice_withDiscountAndTax = 85
                where sellbilldetailid = 7410;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (248, '2026-03-07', 200, 170, 170
                    , 170.8, 170, 170.8, 178.16
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 170, 172.52, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170.8
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170.8
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+178.16
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+172.52
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, '2026-03-07', 200, 170, 170
                    , 170.8, 170, 170.8, 178.16
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 172.52, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170.8
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170.8
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+178.16
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+172.52
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '61', userid = '1', storedetaildate = '2026-03-07 23:02:11' WHERE storedetailid = '248';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('248', '1', '2', '1', '4878', 'اضافة فاتورة مبيعات', 'sellbillController.php', '63', '61', '1', '2026-03-07 23:02:11','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2726188',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2725988','200', '0', '1', 'اضافة فاتورة مبيعات', '4878', '2726188', '2026-03-07 23:02:11', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '200', '200', '2026-03-07', '1', '0', '0', '2026-03-07 23:02:11','اضافة فاتورة مبيعات رقم 4878','1','0',null,'0','4878','sellbillController.php?do=showDetail&sellbillid=4878');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10891', '383', '200', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2725188', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10891', '143', '200', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2829385', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '170', '170', '2026-03-07', '1', '0', '0', '2026-03-07 23:02:11','اضافة فاتورة مبيعات رقم 4878 - صرف البضاعة من المخزن','1','0',null,'0','4878','sellbillController.php?do=showDetail&sellbillid=4878');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10892', '402', '170', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2011672.31', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10892', '382', '170', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1147066.81', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10891,0,10892' where sellbillid=4878;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 200, 170, 170
                    , 170.8, 170, 170.8, 178.16
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,170, 172.52, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170.8
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170.8
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+178.16
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+172.52
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 200, 170, 170
                    , 170.8, 170, 170.8, 178.16
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,170, 172.52, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170.8
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170.8
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+178.16
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+172.52
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 170, 170
                    , 170.8, 170, 170.8, 178.16, 170, 172.52)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+170.8
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+170.8
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+178.16
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+170
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+172.52;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac8fb5165c1 and sellbillId = 4878 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:32:12";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:02:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:02:12', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:32:36";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:02:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:02:36', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac925553446
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 23:02:13', '069ac925553446', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2026-03-07 23:02:36', '', '1', '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','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4879', '0', '2026-03-07 23:02:37', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 23:02:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 638;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('239.96','00520', '4879', '15', '520', '1', '300', '300.00', '0', '', '0', '2026-03-07 23:02:37', '520', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','638-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 = 239.96, meanbuyprice_withDiscount = 239.96
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 239.96
                where sellbilldetailid = 7411;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (520, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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 = '74', userid = '1', storedetaildate = '2026-03-07 23:02:37' WHERE storedetailid = '520';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('520', '1', '1', '1', '4879', 'اضافة فاتورة مبيعات', 'sellbillController.php', '75', '74', '1', '2026-03-07 23:02:37','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2726488',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2726188','300', '0', '1', 'اضافة فاتورة مبيعات', '4879', '2726488', '2026-03-07 23:02:37', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '300', '300', '2026-03-07', '1', '0', '0', '2026-03-07 23:02:37','اضافة فاتورة مبيعات رقم 4879','1','0',null,'0','4879','sellbillController.php?do=showDetail&sellbillid=4879');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10893', '383', '300', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2725488', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10893', '143', '300', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2829685', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '239.96', '239.96', '2026-03-07', '1', '0', '0', '2026-03-07 23:02:37','اضافة فاتورة مبيعات رقم 4879 - صرف البضاعة من المخزن','1','0',null,'0','4879','sellbillController.php?do=showDetail&sellbillid=4879');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10894', '402', '239.96', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2011912.27', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10894', '382', '239.96', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1147306.77', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10893,0,10894' where sellbillid=4879;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, '2026-03-07', 300, 240, 240
                    , 240, 239.96, 239.96, 239.96
                    , 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+239.96, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239.96
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.96
                            , 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, 239.96, 239.96, 239.96, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+240
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+240
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+239.96
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+239.96
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+239.96
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+240
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+240;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac925553446 and sellbillId = 4879 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:32:38";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:02:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:02:38', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:59:32";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:29:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:29:32', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac926f2c5a3
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 23:02:39', '069ac926f2c5a3', '1', '0.00', '0', '0', '1', '600.00', '600', '600', '0', '1', '2026-03-07 23:29:32', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','600','0','','0','0','600','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4880', '0', '2026-03-07 23:29:33', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '600', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 23:02:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 629;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('209.71','00240', '4880', '12', '240', '3', '200', '600.00', '0', '', '0', '2026-03-07 23:29:33', '240', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','629-3,','1','1','0','0','200','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 195.88, lastbuyprice_withDiscount = 209.71, meanbuyprice_withDiscount = 195.81
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 226.22, lastbuyprice_withDiscountAndTax = 209.71
                where sellbilldetailid = 7412;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (240, '2026-03-07', 600, 525, 630
                    , 587.64, 629.13, 587.43, 726.39
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 630, 678.66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+587.64
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+629.13, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+587.43
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+726.39
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+678.66
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+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, '2026-03-07', 600, 525, 630
                    , 587.64, 629.13, 587.43, 726.39
                    , 0, 0, 0, 0
                    , 0, 0, 0, 630, 678.66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+587.64
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+629.13, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+587.43
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+726.39
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+678.66
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2026-03-07 23:29:33' WHERE storedetailid = '240';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('240', '1', '3', '1', '4880', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '19', '1', '2026-03-07 23:29:33','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2727088',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2726488','600', '0', '1', 'اضافة فاتورة مبيعات', '4880', '2727088', '2026-03-07 23:29:33', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '600', '600', '2026-03-07', '1', '0', '0', '2026-03-07 23:29:33','اضافة فاتورة مبيعات رقم 4880','1','0',null,'0','4880','sellbillController.php?do=showDetail&sellbillid=4880');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10895', '383', '600', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2726088', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10895', '143', '600', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2830285', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '629.13', '629.13', '2026-03-07', '1', '0', '0', '2026-03-07 23:29:33','اضافة فاتورة مبيعات رقم 4880 - صرف البضاعة من المخزن','1','0',null,'0','4880','sellbillController.php?do=showDetail&sellbillid=4880');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10896', '402', '629.13', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2012541.4', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10896', '382', '629.13', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1147935.9', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10895,0,10896' where sellbillid=4880;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 600, 525, 630
                    , 587.64, 629.13, 587.43, 726.39
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,630, 678.66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+587.64
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+629.13, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+587.43
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+726.39
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+678.66
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 600, 525, 630
                    , 587.64, 629.13, 587.43, 726.39
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,630, 678.66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+587.64
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+629.13, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+587.43
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+726.39
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+678.66
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 600, 525, 630
                    , 587.64, 629.13, 587.43, 726.39, 630, 678.66)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+600, netSellCostBuyPrice = netSellCostBuyPrice+525
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+630
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+587.64
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+629.13
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+587.43
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+726.39
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+630
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+678.66;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac926f2c5a3 and sellbillId = 4880 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 19:59:34";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:29:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:29:34', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 20:22:25";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:52:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:52:25', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac98bf3a29a
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 23:29:35', '069ac98bf3a29a', '1', '0.00', '0', '0', '1', '1000.00', '1000', '1000', '0', '1', '2026-03-07 23:52:25', '', '1', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','1000','0','','0','0','1000','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4881', '0', '2026-03-07 23:52:26', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1000', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 23:29: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 ('240','00334', '4881', '3', '334', '1', '450', '450.00', '0', '', '0', '2026-03-07 23:52:26', '334', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','','1','1','0','0','450','450','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 = 7413;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (334, '2026-03-07', 450, 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+450, 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, '2026-03-07', 450, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, 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 = '0', userid = '1', storedetaildate = '2026-03-07 23:52:26' WHERE storedetailid = '334';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('334', '1', '1', '1', '4881', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '1', '2026-03-07 23:52: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 ('365','00256', '4881', '1', '256', '1', '550', '550.00', '0', '', '0', '2026-03-07 23:52:26', '256', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','','1','1','0','0','550','550','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 = 7414;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (256, '2026-03-07', 550, 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+550, 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, '2026-03-07', 550, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, 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 = '0', userid = '1', storedetaildate = '2026-03-07 23:52:26' WHERE storedetailid = '256';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('256', '1', '1', '1', '4881', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '1', '2026-03-07 23:52:26','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2728088',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2727088','1000', '0', '1', 'اضافة فاتورة مبيعات', '4881', '2728088', '2026-03-07 23:52:26', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1000', '1000', '2026-03-07', '1', '0', '0', '2026-03-07 23:52:26','اضافة فاتورة مبيعات رقم 4881','1','0',null,'0','4881','sellbillController.php?do=showDetail&sellbillid=4881');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10897', '383', '1000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2727088', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10897', '143', '1000', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2831285', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '605', '605', '2026-03-07', '1', '0', '0', '2026-03-07 23:52:26','اضافة فاتورة مبيعات رقم 4881 - صرف البضاعة من المخزن','1','0',null,'0','4881','sellbillController.php?do=showDetail&sellbillid=4881');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10898', '402', '605', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2013146.4', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10898', '382', '605', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1148540.9', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10897,0,10898' where sellbillid=4881;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 1000, 605, 605
                    , 605, 605, 605, 605
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,605, 605, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1000, sellCostBuyPrice =sellCostBuyPrice+605
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+605, sellCostMeanBuyPrice = sellCostMeanBuyPrice+605
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+605, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+605
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+605
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+605
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+605
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 1000, 605, 605
                    , 605, 605, 605, 605
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,605, 605, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1000, sellCostBuyPrice =sellCostBuyPrice+605
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+605, sellCostMeanBuyPrice = sellCostMeanBuyPrice+605
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+605, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+605
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+605
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+605
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+605
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1000, 605, 605
                    , 605, 605, 605, 605, 605, 605)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1000, netSellCostBuyPrice = netSellCostBuyPrice+605
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+605
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+605
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+605
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+605
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+605
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+605
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+605;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac98bf3a29a and sellbillId = 4881 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 20:22:27";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:52:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:52:27', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 20:24:48";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:54:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:54:48', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac9e1c53b94
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 23:52:28', '069ac9e1c53b94', '1', '0.00', '0', '0', '1', '350.00', '350', '350', '0', '1', '2026-03-07 23:54:49', '', '1', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','350','0','','0','0','350','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4882', '0', '2026-03-07 23:54:49', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '350', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 23:52:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 655;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00533', '4882', '15', '533', '1', '350', '350.00', '0', '', '0', '2026-03-07 23:54:49', '533', '0.00', '-1', '1','0.00','','','0','0','0','0','0','0','0','0','','655-1,','1','1','0','0','350','350','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 = 7415;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (533, '2026-03-07', 350, 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+350, 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, '2026-03-07', 350, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2026-03-07 23:54:49' WHERE storedetailid = '533';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('533', '1', '1', '1', '4882', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '1', '2026-03-07 23:54:49','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2728438',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2728088','350', '0', '1', 'اضافة فاتورة مبيعات', '4882', '2728438', '2026-03-07 23:54:49', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '350', '350', '2026-03-07', '1', '0', '0', '2026-03-07 23:54:49','اضافة فاتورة مبيعات رقم 4882','1','0',null,'0','4882','sellbillController.php?do=showDetail&sellbillid=4882');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10899', '383', '350', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2727438', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10899', '143', '350', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2831635', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '240', '240', '2026-03-07', '1', '0', '0', '2026-03-07 23:54:49','اضافة فاتورة مبيعات رقم 4882 - صرف البضاعة من المخزن','1','0',null,'0','4882','sellbillController.php?do=showDetail&sellbillid=4882');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10900', '402', '240', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2013386.4', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10900', '382', '240', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1148780.9', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10899,0,10900' where sellbillid=4882;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 350, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, 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, '2026-03-07', 350, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, 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, 350, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+350, 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 069ac9e1c53b94 and sellbillId = 4882 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 20:24:50";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:54:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:54:50', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 20:25:45";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:55:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:55:45', '1', 'addAndRetuen', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 069ac9eab9149c
-- ----------------------------------------------------------------------------------------------------

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,sellbilltypeclientid,shipfrom,shipto,paymethodshipping,whatShippingCost) VALUES ('2026-03-07 23:54:51', '069ac9eab9149c', '1', '0.00', '0', '0', '1', '500.00', '500', '500', '0', '1', '2026-03-07 23:55:45', '', '1', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2026-03-07','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','4883', '0', '2026-03-07 23:55:45', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1','2026-03-07 23:54:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 666;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','00541', '4883', '24', '541', '1', '500', '500.00', '0', '', '0', '2026-03-07 23:55:45', '541', '0.00', '0', '1','0.00','','','0','0','0','0','0','0','0','0','','666-1,','1','1','0','0','500','500','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 = 7416;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (541, '2026-03-07', 500, 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+500, 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, '2026-03-07', 500, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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 = '3', userid = '1', storedetaildate = '2026-03-07 23:55:45' WHERE storedetailid = '541';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('541', '1', '1', '1', '4883', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '1', '2026-03-07 23:55:45','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2728938',  userid = '1' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2728438','500', '0', '1', 'اضافة فاتورة مبيعات', '4883', '2728938', '2026-03-07 23:55:45', '1',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '500', '500', '2026-03-07', '1', '0', '0', '2026-03-07 23:55:45','اضافة فاتورة مبيعات رقم 4883','1','0',null,'0','4883','sellbillController.php?do=showDetail&sellbillid=4883');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10901', '383', '500', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', customNameEn = 'الخزنة الرئيسية', nameEn = 'الخزنة الرئيسية', parent = '40', accountNature = '0', theValue = '2727938', theOrder = '0', layingOrder = '12010200002', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = 'Bank and Cash ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:28' WHERE id = '383';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10901', '143', '500', '','0');
UPDATE accountstree SET name = 'ايرادات المبيعات ', customName = 'ايرادات المبيعات ', customNameEn = 'Revenue of Sales', nameEn = 'Revenue of Sales', parent = '142', accountNature = '1', theValue = '2832135', theOrder = '0', layingOrder = '410101', reportid = '2', listId = '2', notes = '', itemfrom = '0', itemtype = '2', itemtype2 = '0', itemtype3 = 'Income ', userid = '1', del = '0', sysdate = '2022-05-08 23:12:40' WHERE id = '143';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '310', '310', '2026-03-07', '1', '0', '0', '2026-03-07 23:55:45','اضافة فاتورة مبيعات رقم 4883 - صرف البضاعة من المخزن','1','0',null,'0','4883','sellbillController.php?do=showDetail&sellbillid=4883');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10902', '402', '310', '','0');
UPDATE accountstree SET name = 'تكلفة التشغيل', customName = 'تكلفة التشغيل', customNameEn = '', nameEn = '', parent = '160', accountNature = '0', theValue = '2013696.4', theOrder = '0', layingOrder = '530101', reportid = '2', listId = '2', notes = '', itemfrom = '1', itemtype = '5', itemtype2 = '0', itemtype3 = '', userid = '1', del = '0', sysdate = '2023-07-25 23:37:18' WHERE id = '402';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10902', '382', '310', '','0');
UPDATE accountstree SET name = 'مخزن1', customName = 'المخزن الرئيسي', customNameEn = 'مخزن1', nameEn = 'مخزن1', parent = '49', accountNature = '0', theValue = '-1149090.9', theOrder = '0', layingOrder = '120202', reportid = '1', listId = '1', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '1', del = '0', sysdate = '2022-05-08 23:13:11' WHERE id = '382';
update sellbill set dailyentryid='10901,0,10902' where sellbillid=4883;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2026-03-07', 500, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2026-03-07', 500, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 500, 310, 310
                    , 310, 310, 310, 310, 310, 310)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, netSellCostBuyPrice = netSellCostBuyPrice+310
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+310
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+310
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+310
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+310
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+310
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+310
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+310;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 069ac9eab9149c and sellbillId = 4883 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2026-03-07 20:25:46";
UPDATE user SET loginip = "::1", lastactivetime = "2026-03-07 23:55:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2026-03-07 23:55:46', '1', 'addsellBill', '::1', '', 'DESKTOP','https://localhost/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
