X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=purchasing%2Fincludes%2Fdb%2Fsupp_payment_db.inc;h=38b1d440f4c4dcf1279df993aa06a73ce243ee4b;hb=de3a75773afa86df1739d14f24399d6f7a46f809;hp=7014cec44a137bf56a23207c783731e70e879452;hpb=da8311619dd73feae101d246a1957b972e00cbd2;p=fa-stable.git diff --git a/purchasing/includes/db/supp_payment_db.inc b/purchasing/includes/db/supp_payment_db.inc index 7014cec4..38b1d440 100644 --- a/purchasing/includes/db/supp_payment_db.inc +++ b/purchasing/includes/db/supp_payment_db.inc @@ -4,54 +4,52 @@ function add_supp_payment($supplier_id, $date_, $payment_type, $bank_account, $amount, $discount, $ref, $memo_) { begin_transaction(); - + $supplier_currency = get_supplier_currency($supplier_id); $bank_account_currency = get_bank_account_currency($bank_account); - + $supp_amount = exchange_from_to($amount, $bank_account_currency, $supplier_currency, $date_); $supp_discount = exchange_from_to($discount, $bank_account_currency, $supplier_currency, $date_); - + // it's a supplier payment $trans_type = 22; /* Create a supp_trans entry for the supplier payment */ - $payment_id = add_supp_trans($trans_type, $supplier_id, $date_, $date_, - $ref, "", -$supp_amount, 0, -$supp_discount); + $payment_id = add_supp_trans($trans_type, $supplier_id, $date_, $date_, + $ref, "", -$supp_amount, 0, -$supp_discount); - // Now debit creditors account with payment + discount + // Now debit creditors account with payment + discount $supplier_accounts = get_supplier_accounts($supplier_id); - + add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payable_account"], 0, 0, - $supp_amount + $supp_discount, $supplier_id); - + $supp_amount + $supp_discount, $supplier_id); + // Now credit discount received account with discounts if ($supp_discount != 0) { add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payment_discount_account"], 0, 0, - -$supp_discount, $supplier_id); + -$supp_discount, $supplier_id); } - - if ($supp_amount != 0) + + if ($supp_amount != 0) { add_gl_trans_supplier($trans_type, $payment_id, $date_, $bank_account, 0, 0, -$supp_amount, $supplier_id); - } + } /*now enter the bank_trans entry */ - add_bank_trans($trans_type, $payment_id, $bank_account, $ref, - $date_, $payment_type, -($amount), payment_person_types::supplier(), - $supplier_id, $bank_account_currency, + add_bank_trans($trans_type, $payment_id, $bank_account, $ref, + $date_, $payment_type, -($amount), payment_person_types::supplier(), + $supplier_id, $bank_account_currency, "Could not add the supplier payment bank transaction"); - - add_comments($trans_type, $payment_id, $date_, $memo_); - - add_forms_for_sys_type($trans_type, $payment_id, payment_person_types::supplier(), $supplier_id); - - references::save_last($ref, $trans_type); - - commit_transaction(); - + + add_comments($trans_type, $payment_id, $date_, $memo_); + + references::save_last($ref, $trans_type); + + commit_transaction(); + return $payment_id; } @@ -60,12 +58,12 @@ function add_supp_payment($supplier_id, $date_, $payment_type, $bank_account, function void_supp_payment($type, $type_no) { begin_transaction(); - + void_bank_trans($type, $type_no, true); void_gl_trans($type, $type_no, true); - void_supp_allocations($type, $type_no); + void_supp_allocations($type, $type_no); void_supp_trans($type, $type_no); - + commit_transaction(); }