HEX
Server: Apache/2.2.15 (CentOS)
System: Linux ip-10-0-2-146.eu-west-1.compute.internal 2.6.32-754.35.1.el6.centos.plus.x86_64 #1 SMP Sat Nov 7 11:33:42 UTC 2020 x86_64
User: root (0)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /www/exchange0old/exchange/custom_reports/5_custom_sql_fixes.sql
UPDATE `manual_transactions` SET `reference_to`='3848,3863,3854,3837,3838,3839,3840,3841,3866,3246,3247,3248,3249,3250,3251,3252,3253,3254,3255,3256,3264,3265,3266,3267,3268,3269,3270,3271,3272,3273,3274,3275,3276,3277,3278,3257,3258,3259,3260,3261,3262,3263,3394,3380,3381,3382,3383,3384,3385,3386,3387,3388,3389,3390,3391,3392,3393,3395,3368,3369,3370,3371,3372,3373,3374,3375,3376,3377,3378,3379,3501,3502,3503,3509,3510,3511,3512,3513,3514,3515,3516,3517,3518,3519,3520,3521,3522,3523,3524,3525,3526,3527,3528,3504,3505,3506,3507,3508,3646,3647,3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3745,3746,3747,3748,3749,3750,3751,3752,3753,3754,3755,3756,3757,3758,3759,3943,3946,3947,3948,3949,3950,3951,3952,3953,3957,3959,3960' 
WHERE `manual_transaction_id`=1681 
LIMIT 1;


INSERT INTO manual_transactions (manual_transaction_id,amount,transaction_type,originator_id,debtors,status,interface,transaction_date,created_at)
VALUES(null,120.89,92,102,191,1,1,"2014-04-17",NOW());
SET @trans_id = LAST_INSERT_ID();
INSERT INTO statements (manual_transaction_id,originator_id)
SELECT manual_transaction_id,originator_id
FROM manual_transactions
WHERE manual_transaction_id=@trans_id;
UPDATE manual_transactions SET amount=amount-120.89 WHERE manual_transaction_id=1681;

DELETE FROM `invoice_reserve` WHERE `invoice_reserve_id`=3074 LIMIT 1;
UPDATE `invoice_master` SET `manual_transaction_id`=0, `auto_assign`=0, `reserve_on`=0 WHERE `invoice_id`=3865 LIMIT 1;




INSERT INTO `invoice_closed` (`closed_ref_id`, `bulk_closed_id`, `invoice_id`, `won_by`, `max_thirty_reserve`) VALUES ('2014-12-31-0000005', 745, 10134, 155, 0.87500);

SET @closed_id = LAST_INSERT_ID();

INSERT INTO `invoice_closed_attributes` (`invoice_closed_id`, `invoice_id`, `maturity_days`, `trade_commission`, `ex_commission`, `agent_commission`, `intermed_commission`, `cdp_cost`, `agreed_buy_rate`, `agreed_sell_rate`, `purchase_discount`, `active_debtors`, `processing_fee`) VALUES (@closed_id, 10134, 180, 0.0625, 0.0625, 0.5, 1.5, 1.5, 3.511, 0.875, 70, 2, 2.5);

UPDATE invoice_closed
LEFT JOIN invoice_closed_attributes ON invoice_closed_attributes.invoice_id = invoice_closed.invoice_id
LEFT JOIN invoice_master ON invoice_master.invoice_id = invoice_closed_attributes.invoice_id
SET invoice_closed_attributes.purchase_discount=70,  invoice_closed.purchase_payment=  (invoice_master.face_value * (70/100)) - invoice_closed_attributes.processing_fee
WHERE invoice_master.invoice_id=10134;

INSERT INTO `invoice_reserve` (`invoice_reserve_id`, `manual_transaction_id`, `invoice_id`, `reserve`, `created_at`) VALUES (null, 7486, 10134, 178.15, '2015-02-06 09:56:50');



UPDATE `invoice_reserve` SET `manual_transaction_id`=1731 WHERE `invoice_reserve_id`=726 LIMIT 1;
UPDATE `invoice_master` SET `manual_transaction_id`=1731 WHERE `invoice_id`=1037 LIMIT 1;