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/exchange2/sql/archive/2016-11-22-TT3015.sql
DELETE invoice_master,invoice_bidding,invoice_bidding_history,invoice_closed,invoice_closed_attributes,invoice_documents
FROM invoice_master
LEFT JOIN invoice_bidding ON invoice_bidding.invoice_id = invoice_master.invoice_id
LEFT JOIN invoice_bidding_history ON invoice_bidding_history.invoice_id = invoice_master.invoice_id
LEFT JOIN invoice_closed ON invoice_closed.invoice_id = invoice_master.invoice_id
LEFT JOIN invoice_closed_attributes ON invoice_closed_attributes.invoice_id = invoice_master.invoice_id
LEFT JOIN invoice_documents ON invoice_documents.invoice_id = invoice_master.invoice_id
WHERE invoice_master.trade_reference_id IN (161003059105,
161004059332,
160620049918,
160811054452,
160527048094,
160527048095,
160527048096,
160527048097,
161003059107,
160930058708,
160930058707,
160527048107,
161003059108,
161108062423,
160831056210,
160831056211
);


INSERT INTO `invoice_master` (`invoice_id`, `po_id`, `invoice_no`, `root_invoice_id`, `debtor_id`, `user_id`, `trade_reference_id`, `face_value`, `document_value`, `revolving`, `revolving_total`, `revolving_months`, `instalment`, `paid_instalments`, `per_instalment_amt`, `no_of_instalments`, `payments_remaining`, `paid_to_debtors`, `buy_out`, `description`, `payment_terms`, `actual_date`, `approved_date`, `expected_date`, `trading_close_date`, `min_advance`, `max_thirty_day_reserve`, `buy_min_advance`, `buy_max_thirty_day_reserve`, `debx`, `invoice_status`, `revolving_status`, `invoice_authorise`, `draft`, `instalment_draft`, `revolving_draft`, `closing_type`, `modified_at`, `modified_by`, `bids`, `sales_type`, `yield`, `buy_yield`, `bid_yield`, `return`, `buy_return`, `bid_return`, `noa_link`, `etr_link`, `noa_status`, `noa_id`, `noa_notifed`, `discount_rate`, `mail_status`, `response_mail_status`, `posting_interface`, `manual_transaction_id`, `auto_assign`, `reserve_on`, `payment_status`, `amendment_status`, `multiple_count`, `created_at`, `authorised_at`, `log_status`, `logapprove_date`, `rejected_date`, `reject_message`, `payment_discount`, `is_auto_send`, `reserve`, `drp_id`, `rerouted`, `spooled`, `c_etr_commission`, `trade_commission`, `processing_fee`, `orpa_id`, `amount_rerouted`) VALUES (NULL, '132615.88', '132615.88', 3100, 3100, 665, 160531063397, 132615.88, 0, 0, 0, 0, 0, 0, 0.00, 0, 0, 0, 1, '', 0, '2016-05-31', '2016-05-31', '2016-06-01', '2016-05-31 13:10:32', 0, 0.875, 0, 0.875, 0, 3, 0, 1, 0, 0, 0, 0, '2016-05-31 13:10:32', 665, 1, 0, 0, 0, 0.097541050630718, 132608.88, 132608.88, 132608.88, NULL, NULL, 0, NULL, NULL, 0.00875, 0, 1, 0, 0, 0, 0, 0, 0, 0, '2016-05-31 13:10:32', '0000-00-00 00:00:00', 1, '2016-05-31 13:11:33', '0000-00-00 00:00:00', '', 0.00, 0, NULL, 0, 0, 1, NULL, NULL, 2.5000, 0, NULL);

SET @invoice_id = LAST_INSERT_ID();

UPDATE `invoice_master`  SET 
    `trade_reference_id`=(CONCAT(DATE_FORMAT(created_at,'%y%m%d'), '000000') + invoice_id) 
WHERE `invoice_id` =@invoice_id ;

INSERT INTO `invoice_bidding` (`invoice_bidding_id`, `user_id`, `invoice_id`, `min_advance`, `max_thirty_reserve`, `bidding_yield`, `buy_out`, `auto_bid`, `bid_time`, `buyout_status`, `flag`, `posted_by`) VALUES (NULL, 191, @invoice_id, 0, 0.87500, 0.097541050630718, 2, 2, '2016-05-31 13:11:43', 0, 0, 1);

SET @invoice_bidding = LAST_INSERT_ID();

INSERT INTO `invoice_bulk_closed` (`bulk_id`, `bulk_ref_id`, `investor_id`, `created_at`) VALUES (NULL, '1605310025055', 191, '2016-05-31 13:11:43');

SET @bulk_id = LAST_INSERT_ID();

UPDATE 
    invoice_bulk_closed c 
    INNER JOIN (
        SELECT CONCAT(DATE_FORMAT(NOW(),'%y%m%d'),REPLACE(CONCAT('ss',(1000000 + ( `bulk_id` ) )),'ss1','0')) as n FROM `invoice_bulk_closed` WHERE bulk_id = @bulk_id
    ) r 
    SET 
        c.bulk_ref_id = r.n
    WHERE
        c.bulk_id = @bulk_id;

INSERT INTO `invoice_closed` (`close_id`, `closed_ref_id`, `bulk_closed_id`, `invoice_id`, `won_by`, `min_advance`, `max_thirty_reserve`, `inv_purchase_price`, `org_purchase_payment`, `purchase_price`, `closed_yield`, `yield_value`, `purchase_payment`, `value_return`, `invoice_bidding_id`, `payment_status`, `close_time`, `accept_status`, `bought_by`) VALUES (NULL, '2016-05-31-0000001', @bulk_id, @invoice_id, 191, 0, 0.87500, 126000.84, 0.00, 126000.84, 0, 31.63, 92828.62, 132613.38, @invoice_bidding, 0, '2016-05-31 13:11:43', 0, 1);

INSERT INTO `invoice_closed_attributes` (`attribute_id`, `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`, `posting_fee`, `processing_fee`, `created_at`) VALUES (NULL, @bulk_id, @invoice_id, 180, 0.0625, 0.0625, 0.5, 1.5, 1.5, 2.171, 0.875, 70, 2, 0, 2.5, '2016-05-31 13:11:44');

INSERT INTO `invoice_documents` (`invoice_document_id`, `invoice_id`, `invoice_document_path`, `invoice_support_document_path`, `purchase_order_document_path`, `modified_at`, `modified_by`) VALUES (NULL, @invoice_id, '', '', '', '2016-05-31 13:10:33', 665);




INSERT INTO `invoice_master` (`invoice_id`, `po_id`, `invoice_no`, `root_invoice_id`, `debtor_id`, `user_id`, `trade_reference_id`, `face_value`, `document_value`, `revolving`, `revolving_total`, `revolving_months`, `instalment`, `paid_instalments`, `per_instalment_amt`, `no_of_instalments`, `payments_remaining`, `paid_to_debtors`, `buy_out`, `description`, `payment_terms`, `actual_date`, `approved_date`, `expected_date`, `trading_close_date`, `min_advance`, `max_thirty_day_reserve`, `buy_min_advance`, `buy_max_thirty_day_reserve`, `debx`, `invoice_status`, `revolving_status`, `invoice_authorise`, `draft`, `instalment_draft`, `revolving_draft`, `closing_type`, `modified_at`, `modified_by`, `bids`, `sales_type`, `yield`, `buy_yield`, `bid_yield`, `return`, `buy_return`, `bid_return`, `noa_link`, `etr_link`, `noa_status`, `noa_id`, `noa_notifed`, `discount_rate`, `mail_status`, `response_mail_status`, `posting_interface`, `manual_transaction_id`, `auto_assign`, `reserve_on`, `payment_status`, `amendment_status`, `multiple_count`, `created_at`, `authorised_at`, `log_status`, `logapprove_date`, `rejected_date`, `reject_message`, `payment_discount`, `is_auto_send`, `reserve`, `drp_id`, `rerouted`, `spooled`, `c_etr_commission`, `trade_commission`, `processing_fee`, `orpa_id`, `amount_rerouted`)  VALUES (NULL, '208248', '208248', 3114, 3114, 559, 161123063400, 208248, 0, 0, 0, 0, 0, 0, 0.00, 0, 0, 0, 1, '', 0, '2016-05-03', '2016-05-03', '2016-05-06', '2016-05-03 11:55:27', 0, 1.000, 0, 1.000, 0, 3, 0, 0, 0, 0, 0, 0, '2016-05-03 11:55:27', 559, 0, 0, 0, 0, 0, 208241, 208241, 0, NULL, NULL, 0, NULL, NULL, 0.00000, 0, 0, 0, 0, 0, 0, 0, 0, 0, '2016-05-03 11:55:27', '0000-00-00 00:00:00', 1, '2016-05-05 11:58:23', '0000-00-00 00:00:00', '', 0.00, 0, NULL, 0, 0, 1, NULL, NULL, 2.5000, 0, NULL);


SET @invoice_id = LAST_INSERT_ID();

UPDATE `invoice_master`  SET 
    `trade_reference_id`=(CONCAT(DATE_FORMAT(created_at,'%y%m%d'), '000000') + invoice_id) 
WHERE `invoice_id` =@invoice_id ;

INSERT INTO `invoice_bidding` (`invoice_bidding_id`, `user_id`, `invoice_id`, `min_advance`, `max_thirty_reserve`, `bidding_yield`, `buy_out`, `auto_bid`, `bid_time`, `buyout_status`, `flag`, `posted_by`) VALUES (NULL, 191, @invoice_id, 0, 1.00000, 0.11252245625691, 2, 2, '2016-05-05 12:01:09', 0, 0, 1);

SET @invoice_bidding = LAST_INSERT_ID();

INSERT INTO `invoice_bulk_closed` (`bulk_id`, `bulk_ref_id`, `investor_id`, `created_at`)  VALUES (NULL, '1611230025058', 191, '2016-05-05 12:01:09');

SET @bulk_id = LAST_INSERT_ID();

UPDATE 
    invoice_bulk_closed c 
    INNER JOIN (
        SELECT CONCAT(DATE_FORMAT(NOW(),'%y%m%d'),REPLACE(CONCAT('ss',(1000000 + ( `bulk_id` ) )),'ss1','0')) as n FROM `invoice_bulk_closed` WHERE bulk_id = @bulk_id
    ) r 
    SET 
        c.bulk_ref_id = r.n
    WHERE
        c.bulk_id = @bulk_id;


INSERT INTO `invoice_closed` (`close_id`, `closed_ref_id`, `bulk_closed_id`, `invoice_id`, `won_by`, `min_advance`, `max_thirty_reserve`, `inv_purchase_price`, `org_purchase_payment`, `purchase_price`, `closed_yield`, `yield_value`, `purchase_payment`, `value_return`, `invoice_bidding_id`, `payment_status`, `close_time`, `accept_status`, `bought_by`)  VALUES (NULL, '2016-05-03-0000001', @bulk_id, @invoice_id, 191, 0, 1.00000, 196460.38, 0.00, 196460.38, 0, -2.50, 104121.50, 208245.50, @invoice_bidding, 0, '2016-05-05 12:01:10', 0, 1);

INSERT INTO `invoice_closed_attributes` (`attribute_id`, `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`, `posting_fee`, `processing_fee`, `created_at`)  VALUES (NULL, @bulk_id, @invoice_id, 180, 0.0625, 0.0625, 0.5, 1.5, 1.5, 2.171, 0.875, 50, 2, 0, 2.5, '2016-05-05 12:01:10');

INSERT INTO `invoice_documents` (`invoice_document_id`, `invoice_id`, `invoice_document_path`, `invoice_support_document_path`, `purchase_order_document_path`, `modified_at`, `modified_by`) VALUES (NULL, @invoice_id, '', '', '', '2016-05-05 13:20:26', 559);




INSERT INTO `invoice_master` (`invoice_id`, `po_id`, `invoice_no`, `root_invoice_id`, `debtor_id`, `user_id`, `trade_reference_id`, `face_value`, `document_value`, `revolving`, `revolving_total`, `revolving_months`, `instalment`, `paid_instalments`, `per_instalment_amt`, `no_of_instalments`, `payments_remaining`, `paid_to_debtors`, `buy_out`, `description`, `payment_terms`, `actual_date`, `approved_date`, `expected_date`, `trading_close_date`, `min_advance`, `max_thirty_day_reserve`, `buy_min_advance`, `buy_max_thirty_day_reserve`, `debx`, `invoice_status`, `revolving_status`, `invoice_authorise`, `draft`, `instalment_draft`, `revolving_draft`, `closing_type`, `modified_at`, `modified_by`, `bids`, `sales_type`, `yield`, `buy_yield`, `bid_yield`, `return`, `buy_return`, `bid_return`, `noa_link`, `etr_link`, `noa_status`, `noa_id`, `noa_notifed`, `discount_rate`, `mail_status`, `response_mail_status`, `posting_interface`, `manual_transaction_id`, `auto_assign`, `reserve_on`, `payment_status`, `amendment_status`, `multiple_count`, `created_at`, `authorised_at`, `log_status`, `logapprove_date`, `rejected_date`, `reject_message`, `payment_discount`, `is_auto_send`, `reserve`, `drp_id`, `rerouted`, `spooled`, `c_etr_commission`, `trade_commission`, `processing_fee`, `orpa_id`, `amount_rerouted`)  VALUES (NULL, '199571', '199571', 3114, 3114, 559, 161123063401, 199571, 0, 0, 0, 0, 0, 0, 0.00, 0, 0, 0, 1, '', 0, '2016-05-03', '2016-05-03', '2016-05-06', '2016-11-23 12:05:44', 0, 1.000, 0, 1.000, 0, 3, 0, 0, 0, 0, 0, 0, '2016-05-03 12:05:44', 559, 0, 0, 0, 0, 0, 199564, 199564, 0, NULL, NULL, 0, NULL, NULL, 0.00000, 0, 0, 0, 0, 0, 0, 0, 0, 0, '2016-05-03 12:05:44', '0000-00-00 00:00:00', 1, '2016-05-05 12:06:03', '0000-00-00 00:00:00', '', 0.00, 0, NULL, 0, 0, 1, NULL, NULL, 2.5000, 0, NULL);

SET @invoice_id = LAST_INSERT_ID();


UPDATE `invoice_master`  SET 
    `trade_reference_id`=(CONCAT(DATE_FORMAT(created_at,'%y%m%d'), '000000') + invoice_id) 
WHERE `invoice_id` =@invoice_id ;

INSERT INTO `invoice_bidding` (`invoice_bidding_id`, `user_id`, `invoice_id`, `min_advance`, `max_thirty_reserve`, `bidding_yield`, `buy_out`, `auto_bid`, `bid_time`, `buyout_status`, `flag`, `posted_by`)  VALUES (NULL, 191, @invoice_id, 0, 1.00000, 0.11252354804751, 2, 2, '2016-05-05 12:10:24', 0, 0, 1);

SET @invoice_bidding = LAST_INSERT_ID();

INSERT INTO `invoice_bulk_closed` (`bulk_id`, `bulk_ref_id`, `investor_id`, `created_at`) VALUES (NULL, '1611230025059', 191, '2016-05-05 12:10:24');

SET @bulk_id = LAST_INSERT_ID();

UPDATE 
    invoice_bulk_closed c 
    INNER JOIN (
        SELECT CONCAT(DATE_FORMAT(NOW(),'%y%m%d'),REPLACE(CONCAT('ss',(1000000 + ( `bulk_id` ) )),'ss1','0')) as n FROM `invoice_bulk_closed` WHERE bulk_id = @bulk_id
    ) r 
    SET 
        c.bulk_ref_id = r.n
    WHERE
        c.bulk_id = @bulk_id;

INSERT INTO `invoice_closed` (`close_id`, `closed_ref_id`, `bulk_closed_id`, `invoice_id`, `won_by`, `min_advance`, `max_thirty_reserve`, `inv_purchase_price`, `org_purchase_payment`, `purchase_price`, `closed_yield`, `yield_value`, `purchase_payment`, `value_return`, `invoice_bidding_id`, `payment_status`, `close_time`, `accept_status`, `bought_by`)  VALUES (NULL, '2016-05-05-0000002', @bulk_id, @invoice_id, 191, 0, 1.00000, 188274.53, 0.00, 188274.53, 0, 56.34, 99783.00, 199568.50, @invoice_bidding, 0, '2016-05-05 12:10:24', 0, 1);

INSERT INTO `invoice_closed_attributes` (`attribute_id`, `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`, `posting_fee`, `processing_fee`, `created_at`)  VALUES (NULL, @bulk_id, @invoice_id, 180, 0.0625, 0.0625, 0.5, 1.5, 1.5, 2.171, 0.875, 50, 2, 0, 2.5, '2016-05-05 12:10:24');

INSERT INTO `invoice_documents` (`invoice_document_id`, `invoice_id`, `invoice_document_path`, `invoice_support_document_path`, `purchase_order_document_path`, `modified_at`, `modified_by`) VALUES (NULL, @invoice_id, '', '', '', '2016-05-05 14:02:27', 559);


UPDATE `manual_transactions` SET `transaction_type`=19, `debtor_id`=3114 WHERE  `manual_transaction_id` IN (42323,40814);


INSERT INTO `debtors_detail` (  `debtor_name`,`debtor_contact_first_name`,`debtor_contact_last_name`, `debtor_company_registration_number`,`nace_id`,`nace_group_id`,`customer_since`, `total_debtor_value` ,`average_payment_cycle` ,`no_credit_note_issued` , `avg_invoice_predicted_annum` ,`avg_revenue_predicted_annum` ,`debtor_risk` , `debtor_limit` ,`address_id` ,`billing_address_id` ,`contact_address_id`, `currency_id`,`created_by` ,`modified_at` ,`modified_by`,`founded`,`trade_name` , `previous_name`,`parent_id`, created , `credit_limit`,`type`,`payment_discount`, `trade_limit` ) VALUES  ('Asba Meats Limited','Tareq','Khan',
                            'IE498814', '', '', 
                            '2011', '', '0', 
                            '0', '0', '1', 
                            '0', '0', NULL , NULL , NULL ,'1', 
                            '158', NOW(),
                            '158','00000000-00000000-00000000', '', 
                            '','0', NOW(), '0','debtor','0', '1');

SET @debtor_id=LAST_INSERT_ID();
                            
UPDATE `debtors_detail`  
SET `debtor_reference_id` = (CONCAT(DATE_FORMAT(created,'%Y%m%d'), '000000') + debtor_id)  
WHERE debtor_id=@debtor_id  
LIMIT 1;

INSERT INTO `debtor_relation` (`trader_id` ,`debtor_id` ,`organisation_id`,`child_id` ,`created`)
VALUES  ('158', @debtor_id, '143', '0',CURRENT_TIMESTAMP);

INSERT INTO `address_details` (`address_line_one` ,`address_line_two` ,`address_area` , `address_city` ,`address_state` ,`address_country` , `address_zipcode` ,`address_phone_country` ,`address_phone_code` , `address_phone` ,`address_mobile_country` ,`address_mobile_code` , `address_mobile` ,`address_fax_country` ,`address_fax_code` , `address_fax` ,`address_email` ,`address_all_details` , `modified_at` ,`modified_by`) VALUES ('The Old Creamery', 'Farran', 'NULL','Ardagh',
                            'Limerick', '104', 'V42 PC95', 
                            '00353', '027', '3380', 
                            'NULL', 'NULL', 'NULL', '00353', '', 
                            '', 'accounts@asbameats.com','NULL',NOW(), 
                            '158');

SET @address1=LAST_INSERT_ID();
                            
INSERT INTO `address_details` (`address_line_one` ,`address_line_two` ,`address_area` , `address_city` ,`address_state` ,`address_country` , `address_zipcode` ,`address_phone_country` ,`address_phone_code` , `address_phone` ,`address_mobile_country` ,`address_mobile_code` , `address_mobile` ,`address_fax_country` ,`address_fax_code` , `address_fax` ,`address_email` ,`address_all_details` , `modified_at` ,`modified_by`) VALUES ('The Old Creamery', 'Farran', 'NULL','Ardagh',
                            'Limerick', '104', 'V42 PC95', 
                            '00353', '027', '3380', 
                            'NULL', 'NULL', 'NULL', '00353', '', 
                            '', 'accounts@asbameats.com','NULL',NOW(), 
                            '158');
    
SET @address2=LAST_INSERT_ID();    
                           
INSERT INTO `address_details`  (`address_line_one` ,`address_line_two` ,`address_area` , `address_city` ,`address_state` ,`address_country` , `address_zipcode` ,`address_phone_country` ,`address_phone_code` , `address_phone` ,`address_mobile_country` ,`address_mobile_code` , `address_mobile` ,`address_fax_country` ,`address_fax_code` , `address_fax` ,`address_email` ,`address_all_details` , `modified_at` ,`modified_by`) VALUES('NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', '00353', 
                            '027', '3380', 'NULL', 'NULL', 'NULL', 'NULL',
                            'NULL', 'NULL', 'accounts@asbameats.com','NULL',NOW(), 
                            '158');

SET @address3=LAST_INSERT_ID();                            
                            
UPDATE `debtors_detail` 
    SET `filepdf` = '', `filescv` = '', `address_id` = @address1 , `billing_address_id` = @address2 ,`contact_address_id` = @address3  
    WHERE `debtor_id` =@debtor_id 
    LIMIT 1;

                            
INSERT INTO debtor_history_report(debtor_id,report_type,report_number,  report_date,report_branch,report_total) 
VALUES  (@debtor_id,'SR','0','0000-00-00','','0'),(@debtor_id,'SI','0','0000-00-00','','0');

INSERT INTO `debtor_contacts`(`debtor_id`,`firstname`,`lastname`,`phone`,`email`,`etr_delivery`) VALUES(@debtor_id,'Tareq','Khan','003530273380','accounts@asbameats.com','1');