=== New Payment Request ===
Supplier ID: 37, Amount: 135.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 135.00
Purchase due rows found: 1
Paying purchase due: ref=pur-148, amount=50
Inserted into supplier_acc: ref=pur-148, amount=50, id=164
Rest amount after purchase due: 85
Inserting advance payment: 85
Inserted into supplier_acc: ref=adv, amount=85, id=165
Total inserted: 135
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 85.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 85.00
Purchase due rows found: 0
Rest amount after purchase due: 85.00
Inserting advance payment: 85.00
Inserted into supplier_acc: ref=adv, amount=85.00, id=166
Total inserted: 85
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 85.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 85.00
Purchase due rows found: 0
Rest amount after purchase due: 85.00
Inserting advance payment: 85.00
Inserted into supplier_acc: ref=adv, amount=85.00, id=167
Total inserted: 85
=== UPDATE ADVANCE ===
ID: 166
Advance Money: 85.00
Note: 
Ref: 
Affected rows: 1
SUCCESS: Record updated
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 85.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 85.00
Purchase due rows found: 0
Rest amount after purchase due: 85.00
Inserting advance payment: 85.00
Inserted into supplier_acc: ref=adv, amount=85.00, id=168
Total inserted: 85
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 85.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 85.00
Purchase due rows found: 0
Rest amount after purchase due: 85.00
Inserting advance payment: 85.00
Inserted into supplier_acc: ref=adv, amount=85.00, id=179
Total inserted: 85
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 85.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 85.00
Purchase due rows found: 0
Rest amount after purchase due: 85.00
Inserting advance payment: 85.00
Inserted into supplier_acc: ref=adv, amount=85.00, id=180
Total inserted: 85
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 85.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 85.00
Purchase due rows found: 0
Rest amount after purchase due: 85.00
Inserting advance payment: 85.00
Inserted into supplier_acc: ref=adv, amount=85.00, id=181
Total inserted: 85
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 135.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 135.00
Purchase due rows found: 0
Rest amount after purchase due: 135.00
Inserting advance payment: 135.00
Inserted into supplier_acc: ref=adv, amount=135.00, id=182
Total inserted: 135
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 135.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 135.00
Purchase due rows found: 0
Rest amount after purchase due: 135.00
Inserting advance payment: 135.00
Inserted into supplier_acc: ref=adv, amount=135.00, id=183
Total inserted: 135
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 235.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 235.00
Purchase due rows found: 0
Rest amount after purchase due: 235.00
Inserting advance payment: 235.00
Inserted into supplier_acc: ref=adv, amount=235.00, id=184
Total inserted: 235
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 235.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 235.00
Purchase due rows found: 0
Rest amount after purchase due: 235.00
Inserting advance payment: 235.00
Inserted into supplier_acc: ref=adv, amount=235.00, id=185
Total inserted: 235
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 235.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 235.00
Purchase due rows found: 1
Paying purchase due: ref=pur-150, amount=20
Inserted into supplier_acc: ref=pur-150, amount=20, id=187
Rest amount after purchase due: 215
Inserting advance payment: 215
Inserted into supplier_acc: ref=adv, amount=215, id=188
Total inserted: 235
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 215.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 215.00
Purchase due rows found: 1
Paying purchase due: ref=pur-151, amount=20
Inserted into supplier_acc: ref=pur-151, amount=20, id=190
Rest amount after purchase due: 195
Inserting advance payment: 195
Inserted into supplier_acc: ref=adv, amount=195, id=191
Total inserted: 215
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 185.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 185.00
Purchase due rows found: 1
Paying purchase due: ref=pur-151, amount=20
Inserted into supplier_acc: ref=pur-151, amount=20, id=194
Rest amount after purchase due: 165
Inserting advance payment: 165
Inserted into supplier_acc: ref=adv, amount=165, id=195
Total inserted: 185
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 40.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 40.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=199
Rest amount after purchase due: 25
Inserting advance payment: 25
Inserted into supplier_acc: ref=adv, amount=25, id=200
Total inserted: 40
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=201, note=Adjusted by adv
Rest amount after purchase due: 10
Inserting advance payment: 10
Inserted into supplier_acc: ref=adv, amount=10, id=202, note=Adjusted by adv (Advance Payment)
Total inserted: 25
Transaction committed successfully!
Inserted into supplier_acc: ref=adv, amount=15, id=203, note=Adjusted By-200
=== New Payment Request ===
Supplier ID: 37, Amount: 30.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 30.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=204, note=Adjusted by adv
Rest amount after purchase due: 15
Inserting advance payment: 15
Inserted into supplier_acc: ref=adv, amount=15, id=205, note=Adjusted by adv (Advance Payment)
Total inserted: 30
Transaction committed successfully!
Inserted into supplier_acc: ref=adv, amount=15, id=206, note=Rest of Advance Id-203
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=207, note=Adjusted by adv
Rest amount after purchase due: 10
Inserting advance payment: 10
Inserted into supplier_acc: ref=adv, amount=10, id=208, note=Adjusted by adv (Advance Payment)
Total inserted: 25
Transaction committed successfully!
Inserted into supplier_acc: ref=adv, amount=15, id=209, note=Rest of Advance Id-200
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=210, note=Adjusted by adv
Rest amount after purchase due: 10
Inserting advance payment: 10
Inserted into supplier_acc: ref=adv, amount=10, id=211, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=212, note=Paid By Advance-200
Rest amount after purchase due: 10
Inserting advance payment: 10
Inserted into supplier_acc: ref=adv, amount=10, id=213, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=214, note=Paid By Advance Id-200
Rest amount after purchase due: 10
Inserting advance payment: 10
Inserted into supplier_acc: ref=adv, amount=10, id=215, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 10.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 10.00
Purchase due rows found: 0
Rest amount after purchase due: 10.00
Inserting advance payment: 10.00
Inserted into supplier_acc: ref=adv, amount=10.00, id=216, note=Rest of Advance Id-215
Total inserted: 10
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 10.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 10.00
Purchase due rows found: 0
Rest amount after purchase due: 10.00
Inserting advance payment: 10.00
Inserted into supplier_acc: ref=adv, amount=10.00, id=217, note=Rest of Advance Id-215
Total inserted: 10
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 0
Rest amount after purchase due: 25.00
Inserting advance payment: 25.00
Inserted into supplier_acc: ref=adv, amount=25.00, id=218, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 0
Rest amount after purchase due: 25.00
Inserting advance payment: 25.00
Inserted into supplier_acc: ref=adv, amount=25.00, id=219, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 0
Rest amount after purchase due: 25.00
Inserting advance payment: 25.00
Inserted into supplier_acc: ref=adv, amount=25.00, id=220, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 0
Rest amount after purchase due: 25.00
Inserting advance payment: 25.00
Inserted into supplier_acc: ref=adv, amount=25.00, id=221, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=222, note=Paid By Advance Id-200
Rest amount after purchase due: 10
Inserting advance payment: 10
Inserted into supplier_acc: ref=adv, amount=10, id=223, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 0
Rest amount after purchase due: 25.00
Inserting advance payment: 25.00
Inserted into supplier_acc: ref=adv, amount=25.00, id=224, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 30.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 30.00
Purchase due rows found: 0
Rest amount after purchase due: 30.00
Inserting advance payment: 30.00
Inserted into supplier_acc: ref=adv, amount=30.00, id=225, note=Rest of Advance Id-203
Total inserted: 30
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=226, note=Paid By Advance Id-200
Rest amount after purchase due: 10
Inserting advance payment: 10
Inserted into supplier_acc: ref=adv, amount=10, id=227, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=228, note=Paid By Advance Id-200
Rest amount after purchase due: 10
Inserting advance payment: 10
Inserted into supplier_acc: ref=adv, amount=10, id=229, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 10.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 10.00
Purchase due rows found: 0
Rest amount after purchase due: 10.00
Inserting advance payment: 10.00
Inserted into supplier_acc: ref=adv, amount=10.00, id=230, note=Rest of Advance Id-229
Total inserted: 10
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 25.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 25.00
Purchase due rows found: 1
Paying purchase due: ref=pur-152, amount=15
Inserted into supplier_acc: ref=pur-152, amount=15, id=231, note=Paid By Advance Id-200
Rest amount after purchase due: 10
Inserting advance payment: 10
Inserted into supplier_acc: ref=adv, amount=10, id=232, note=Rest of Advance Id-200
Total inserted: 25
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: , Amount: 10909.00
=== New Payment Request ===
Supplier ID: , Amount: 15500.00
=== New Payment Request ===
customer ID: 3, Amount: 15500.00
ERROR: Unknown column 'customer_id' in 'where clause'
=== New Payment Request ===
customer ID: 3, Amount: 15500.00
ERROR: Unknown column 'customer_id' in 'where clause'
=== New Payment Request ===
customer ID: 3, Amount: 15500.00
ERROR: Unknown column 'customer_id' in 'where clause'
=== New Payment Request ===
customer ID: , Amount: 15500.00
=== New Payment Request ===
customer ID: 3, Amount: 15500.00
ERROR: Unknown column 'customer_id' in 'where clause'
=== New Payment Request ===
customer ID: 3, Amount: 15500.00
OB Query Result: Array
(
    [id] => 3
    [open_balance] => 3000
    [ttl_ob_paid] => 3000.00
    [ob_due] => 0.00
)

OB: 3000, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 15500.00
Sale due rows found: 1
Paying Sale due: ref=sel-100, amount=300
Inserted into customer_acc: ref=sel-100, amount=300, id=294, note=Paid By Advance Id-292
Rest amount after Sale due: 15200
Inserting advance payment: 15200
Inserted into customer_acc: ref=adv, amount=15200, id=295, note=Rest of Advance Id-292
Total inserted: 15500
Transaction committed successfully!
=== New Payment Request ===
customer ID: 3, Amount: 15200.00
OB Query Result: Array
(
    [id] => 3
    [open_balance] => 3000
    [ttl_ob_paid] => 3000.00
    [ob_due] => 0.00
)

OB: 3000, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 15200.00
Sale due rows found: 1
Paying Sale due: ref=sel-101, amount=200
Inserted into customer_acc: ref=sel-101, amount=200, id=297, note=Paid By Advance Id-295
Rest amount after Sale due: 15000
Inserting advance payment: 15000
Inserted into customer_acc: ref=adv, amount=15000, id=298, note=Rest of Advance Id-295
Total inserted: 15200
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 37, Amount: 203.00
OB Query Result: Array
(
    [ob] => 3000
    [supplier_ob_due] => 0
)

OB: 3000, OD: 0
OD = 0, skipping opening balance
Rest amount after OB: 203.00
Purchase due rows found: 1
Paying purchase due: ref=pur-80, amount=203.00
Inserted into supplier_acc: ref=pur-80, amount=203.00, id=250, note=Paid By Advance Id-232
Rest amount after purchase due: 0
Total inserted: 203
Transaction committed successfully!
=== New Payment Request ===
customer ID: 21, Amount: 276250.00
OB Query Result: Array
(
    [id] => 21
    [open_balance] => 0
    [ttl_ob_paid] => 
    [ob_due] => 
)

OB: 0, OD: NULL
OD is NULL, checking OB: 0
Rest amount after OB: 276250.00
Sale due rows found: 1
Paying Sale due: ref=sel-94, amount=270000
Inserted into customer_acc: ref=sel-94, amount=270000, id=257, note=Paid By Advance Id-249
Rest amount after Sale due: 6250
Inserting advance payment: 6250
Inserted into customer_acc: ref=adv, amount=6250, id=258, note=Rest of Advance Id-249
Total inserted: 276250
Transaction committed successfully!
=== New Payment Request ===
customer ID: 20, Amount: 200000.00
OB Query Result: Array
(
    [id] => 20
    [open_balance] => 0
    [ttl_ob_paid] => 
    [ob_due] => 
)

OB: 0, OD: NULL
OD is NULL, checking OB: 0
Rest amount after OB: 200000.00
Sale due rows found: 1
Paying Sale due: ref=sel-95, amount=135000
Inserted into customer_acc: ref=sel-95, amount=135000, id=260, note=Paid By Advance Id-251
Rest amount after Sale due: 65000
Inserting advance payment: 65000
Inserted into customer_acc: ref=adv, amount=65000, id=261, note=Rest of Advance Id-251
Total inserted: 200000
Transaction committed successfully!
=== New Payment Request ===
customer ID: 3, Amount: 493900.00
OB Query Result: Array
(
    [id] => 3
    [open_balance] => 0
    [ttl_ob_paid] => 
    [ob_due] => 
)

OB: 0, OD: NULL
OD is NULL, checking OB: 0
Rest amount after OB: 493900.00
Sale due rows found: 1
Paying Sale due: ref=sel-96, amount=487800
Inserted into customer_acc: ref=sel-96, amount=487800, id=263, note=Paid By Advance Id-250
Rest amount after Sale due: 6100
Inserting advance payment: 6100
Inserted into customer_acc: ref=adv, amount=6100, id=264, note=Rest of Advance Id-250
Total inserted: 493900
Transaction committed successfully!
=== New Payment Request ===
customer ID: 22, Amount: 242250.00
OB Query Result: Array
(
    [id] => 22
    [open_balance] => 0
    [ttl_ob_paid] => 
    [ob_due] => 
)

OB: 0, OD: NULL
OD is NULL, checking OB: 0
Rest amount after OB: 242250.00
Sale due rows found: 1
Paying Sale due: ref=sel-97, amount=135000
Inserted into customer_acc: ref=sel-97, amount=135000, id=266, note=Paid By Advance Id-245
Rest amount after Sale due: 107250
Inserting advance payment: 107250
Inserted into customer_acc: ref=adv, amount=107250, id=267, note=Rest of Advance Id-245
Total inserted: 242250
Transaction committed successfully!
=== New Payment Request ===
customer ID: 19, Amount: 251200.00
OB Query Result: Array
(
    [id] => 19
    [open_balance] => 0
    [ttl_ob_paid] => 
    [ob_due] => 
)

OB: 0, OD: NULL
OD is NULL, checking OB: 0
Rest amount after OB: 251200.00
Sale due rows found: 1
Paying Sale due: ref=sel-99, amount=251200.00
Inserted into customer_acc: ref=sel-99, amount=251200.00, id=270, note=Paid By Advance Id-246
Rest amount after Sale due: 0
Total inserted: 251200
Transaction committed successfully!
=== New Payment Request ===
customer ID: 2, Amount: 4500.00
OB Query Result: Array
(
    [id] => 2
    [open_balance] => 500
    [ttl_ob_paid] => 500.00
    [ob_due] => 0.00
)

OB: 500, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 4500.00
Sale due rows found: 1
Paying Sale due: ref=sel-100, amount=2900
Inserted into customer_acc: ref=sel-100, amount=2900, id=286, note=Paid By Advance Id-284
Rest amount after Sale due: 1600
Inserting advance payment: 1600
Inserted into customer_acc: ref=adv, amount=1600, id=287, note=Rest of Advance Id-284
Total inserted: 4500
Transaction committed successfully!
=== New Payment Request ===
customer ID: 14, Amount: 20.00
OB Query Result: Array
(
    [id] => 14
    [open_balance] => 30
    [ttl_ob_paid] => 30.00
    [ob_due] => 0.00
)

OB: 30, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 20.00
Sale due rows found: 2
Paying Sale due: ref=sel-130, amount=20.00
Inserted into customer_acc: ref=sel-130, amount=20.00, id=379, note=Paid By Advance Id-373
Rest amount after Sale due: 0
Total inserted: 20
Transaction committed successfully!
=== New Payment Request ===
customer ID: 14, Amount: 30.00
OB Query Result: Array
(
    [id] => 14
    [open_balance] => 30
    [ttl_ob_paid] => 30.00
    [ob_due] => 0.00
)

OB: 30, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 30.00
Sale due rows found: 2
Paying Sale due: ref=sel-130, amount=30.00
Inserted into customer_acc: ref=sel-130, amount=30.00, id=380, note=Paid By Advance Id-374
Rest amount after Sale due: 0
Total inserted: 30
Transaction committed successfully!
=== New Payment Request ===
customer ID: 14, Amount: 100.00
OB Query Result: Array
(
    [id] => 14
    [open_balance] => 30
    [ttl_ob_paid] => 30.00
    [ob_due] => 0.00
)

OB: 30, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 100.00
Sale due rows found: 1
Paying Sale due: ref=sel-133, amount=70
Inserted into customer_acc: ref=sel-133, amount=70, id=382, note=Paid By Advance Id-375
Rest amount after Sale due: 30
Inserting advance payment: 30
Inserted into customer_acc: ref=adv, amount=30, id=383, note=Rest of Advance Id-375
Total inserted: 100
Transaction committed successfully!
=== New Payment Request ===
customer ID: 14, Amount: 120.00
OB Query Result: Array
(
    [id] => 14
    [open_balance] => 30
    [ttl_ob_paid] => 30.00
    [ob_due] => 0.00
)

OB: 30, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 120.00
Sale due rows found: 1
Paying Sale due: ref=sel-135, amount=20
Inserted into customer_acc: ref=sel-135, amount=20, id=389, note=Paid By Advance Id-387
Rest amount after Sale due: 100
Inserting advance payment: 100
Inserted into customer_acc: ref=adv, amount=100, id=390, note=Rest of Advance Id-387
Total inserted: 120
Transaction committed successfully!
=== New Payment Request ===
customer ID: 14, Amount: 100.00
OB Query Result: Array
(
    [id] => 14
    [open_balance] => 30
    [ttl_ob_paid] => 30.00
    [ob_due] => 0.00
)

OB: 30, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 100.00
Sale due rows found: 1
Paying Sale due: ref=sel-136, amount=20
Inserted into customer_acc: ref=sel-136, amount=20, id=392, note=Paid By Advance Id-390
Rest amount after Sale due: 80
Inserting advance payment: 80
Inserted into customer_acc: ref=adv, amount=80, id=393, note=Rest of Advance Id-390
Total inserted: 100
Transaction committed successfully!
=== New Payment Request ===
customer ID: 14, Amount: 80, Adv ID: 393
OB Query Result: Array
(
    [id] => 14
    [open_balance] => 30
    [ttl_ob_paid] => 30.00
    [ob_due] => 0.00
)

OB: 30, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 80
Sale due rows found: 1
Paying Sale due: ref=sel-137, amount=20
Inserted into customer_acc: ref=sel-137, amount=20, id=395, note=Paid By Advance Id-393
Rest amount after Sale due: 60
Inserting advance payment: 60
Inserted into customer_acc: ref=adv, amount=60, id=396, note=Rest of Advance Id-393
Total inserted: 80
Transaction committed successfully!
=== New Payment Request ===
customer ID: 14, Amount: 60, Adv ID: 396
OB Query Result: Array
(
    [id] => 14
    [open_balance] => 30
    [ttl_ob_paid] => 30.00
    [ob_due] => 0.00
)

OB: 30, OD: 0.00
OD = 0, skipping opening balance
Rest amount after OB: 60
Sale due rows found: 2
Paying Sale due: ref=sel-138, amount=10
Inserted into customer_acc: ref=sel-138, amount=10, id=399, note=Paid By Advance Id-396
Paying Sale due: ref=sel-139, amount=20
Inserted into customer_acc: ref=sel-139, amount=20, id=400, note=Paid By Advance Id-396
Rest amount after Sale due: 30
Inserting advance payment: 30
Inserted into customer_acc: ref=adv, amount=30, id=401, note=Rest of Advance Id-396
Total inserted: 60
Transaction committed successfully!
=== New Payment Request ===
=== New Payment Request ===
=== New Payment Request ===
Supplier ID: 80, Amount: 10, Adv ID: 351
OB Query Result: Array
(
    [supplier_id] => 80
    [ob] => 30
    [ttl_supplier_ob_paid] => 60.00
    [supplier_ob_due] => -30
)

OB: 30, OD: -30
OD = 0, skipping opening balance
Rest amount after OB: 10
Sale due rows found: 1
Paying Purchase due: ref=pur-128, amount=10
Inserted into supplier_acc: ref=pur-128, amount=10, id=355, note=Paid By Advance Id-351
Rest amount after Purchase due: 0
Total inserted: 10
ERROR: Table 'iam.purchase_order' doesn't exist
Stack trace: #0 C:\xampp\htdocs\iam\advanced_adjustment_supplier.php(251): mysqli_prepare(Object(mysqli), 'SELECT po_numbe...')
#1 {main}
=== New Payment Request ===
Supplier ID: 80, Amount: 10, Adv ID: 351
OB Query Result: Array
(
    [supplier_id] => 80
    [ob] => 30
    [ttl_supplier_ob_paid] => 60.00
    [supplier_ob_due] => -30
)

OB: 30, OD: -30
OD = 0, skipping opening balance
Rest amount after OB: 10
Sale due rows found: 1
Paying Purchase due: ref=pur-128, amount=10
Inserted into supplier_acc: ref=pur-128, amount=10, id=356, note=Paid By Advance Id-351
Rest amount after Purchase due: 0
Total inserted: 10
ERROR: Table 'iam.purchase_order' doesn't exist
Stack trace: #0 C:\xampp\htdocs\iam\advanced_adjustment_supplier.php(251): mysqli_prepare(Object(mysqli), 'SELECT po_numbe...')
#1 {main}
=== New Payment Request ===
Supplier ID: 80, Amount: 10, Adv ID: 351
OB Query Result: Array
(
    [supplier_id] => 80
    [ob] => 30
    [ttl_supplier_ob_paid] => 60.00
    [supplier_ob_due] => -30
)

OB: 30, OD: -30
OD = 0, skipping opening balance
Rest amount after OB: 10
Sale due rows found: 1
Paying Purchase due: ref=pur-128, amount=10
Inserted into supplier_acc: ref=pur-128, amount=10, id=357, note=Paid By Advance Id-351
Rest amount after Purchase due: 0
Total inserted: 10
=== New Payment Request ===
Supplier ID: 80, Amount: 10, Adv ID: 351
OB Query Result: Array
(
    [supplier_id] => 80
    [ob] => 30
    [ttl_supplier_ob_paid] => 60.00
    [supplier_ob_due] => -30
)

OB: 30, OD: -30
OD = 0, skipping opening balance
Rest amount after OB: 10
Purchase due rows found: 1
Paying Purchase due: ref=pur-128, amount=10
Inserted into supplier_acc: ref=pur-128, amount=10, id=358, note=Paid By Advance Id-351
Rest amount after Purchase due: 0
Total inserted: 10
=== New Payment Request ===
Supplier ID: 80, Amount: 10, Adv ID: 351
OB Query Result: Array
(
    [supplier_id] => 80
    [ob] => 30
    [ttl_supplier_ob_paid] => 60.00
    [supplier_ob_due] => -30
)

OB: 30, OD: -30
OD = 0, skipping opening balance
Rest amount after OB: 10
Purchase due rows found: 1
Paying Purchase due: ref=pur-128, amount=10
Inserted into supplier_acc: ref=pur-128, amount=10, id=359, note=Paid By Advance Id-351
Rest amount after Purchase due: 0
Total inserted: 10
Transaction committed successfully!
=== New Payment Request ===
Supplier ID: 80, Amount: 270, Adv ID: 353
OB Query Result: Array
(
    [supplier_id] => 80
    [ob] => 30
    [ttl_supplier_ob_paid] => 60.00
    [supplier_ob_due] => -30
)

OB: 30, OD: -30
OD = 0, skipping opening balance
Rest amount after OB: 270
Purchase due rows found: 1
Paying Purchase due: ref=pur-128, amount=110
Inserted into supplier_acc: ref=pur-128, amount=110, id=360, note=Paid By Advance Id-353
Rest amount after Purchase due: 160
Inserting advance payment: 160
Inserted into supplier_acc: ref=adv, amount=160, id=361, note=Rest of Advance Id-353
Total inserted: 270
Transaction committed successfully!
