Project

General

Profile

Actions

VOC support #2987

closed

Issue billing for tentative reservation

Added by Tracy Tran about 2 months ago. Updated about 1 month ago.

Status:
완료성공(Resolve)
Priority:
보통(Normal)
Assignee:
Target version:
Start date:
02/05/2026
Due date:
02/05/2026
% Done:

100%

Estimated time:
Part:
Build env.:
Prod

Description

Dear Tom,

As you know that our system could not issue billing with minus amount. However, JPAC team informed that We were not able to issue the billing by combining it with other bookings.

In accounting practice, when an error is found in the amount of a past booking, it is common not to modify the original data. Instead, the incorrect amount is recorded as a negative entry and the correct amount is recorded as a positive entry.

This is because revising the original data would make it difficult to identify the change when reviewing the records later.

Therefore, we would appreciate it if you could enable the system to create payment data even for negative amounts.

Booking K26012111843H01

Please support to issue billing for this booking.


Files

picture892-1.png (11.3 KB) picture892-1.png Tom Dong, 02/05/2026 03:01 AM
picture386-1.png (134 KB) picture386-1.png Tracy Tran, 02/05/2026 03:42 AM
Actions #1

Updated by Tom Dong about 1 month ago

Actions #2

Updated by Tom Dong about 1 month ago

  • Status changed from 신규(New) to 진행(Doing)
Actions #3

Updated by Tom Dong about 1 month ago

VOC Issue Billing - SQL Script

Booking Details:

Field Value
Booking Code K26012111843H01
Hotel Code 687288
Vendor Code 601769
Vendor Sum Amount -12,895.00 JPY (negative amount)
Check-in 2026-01-01
Check-out 2026-01-02
Booking Status BKS05 (Tentative)
Bank Account Seq 121741

Issue:

The system normally cannot issue billing with negative amounts. This booking has VENDOR_SUM_AMOUNT = -12,895 JPY.


SQL to Issue Billing:

-- =====================================================
-- VOC ISSUE BILLING for K26012111843H01 (Negative Amount)
-- Task: #2987
-- =====================================================

-- Step 1: Clear temp table
DELETE FROM temp_voc_issue_billing WHERE BillingNo IS NOT NULL;

-- Step 2: Insert booking data into temp table
INSERT INTO temp_voc_issue_billing (AppliedFromDate, AppliedToDate, BookingItemCode, HotelCode, VendorCode, BankAccountNumber, Currency, DepositDueDate) 
VALUES
    ('2026-01-01', '2026-01-31', 'K26012111843H01', 687288, 601769, '普通 3463210', 'JPY', '2026-02-28');

-- Step 3: Insert PM_INVOICE_MASTER
INSERT INTO PM_INVOICE_MASTER (
    SALES_OR_VENDOR, ISSUE_COMP_CODE, TRADER_COMP_CODE, CHECK_IN_OR_OUT,
    APPLIED_FROM_DATE, APPLIED_TO_DATE, CURRENCY_CODE,
    INVOICE_AMOUNT, PAID_AMOUNT, BALANCE_AMOUNT, BANK_ACCOUNT_SEQ,
    ISSUE_DATETIME, DEPOSIT_DUE_DATE, REMIT_DATE, BILLING_STATUS_CODE,
    CONTROL_REMARK, FIRST_INSERT_UNO, FIRST_INSERT_DATETIME, LAST_UPDATE_UNO, LAST_UPDATE_DATETIME, ADJUSTMENT_AMOUNT
)
SELECT DISTINCT
    'V' AS SaleOrVendor,
    tvib.VendorCode,
    tvib.VendorCode,
    'I' AS CheckInOrOut,
    tvib.AppliedFromDate,
    tvib.AppliedToDate,
    tvib.Currency,
    0 AS invocieAmount,
    0 AS PaidAmount,
    0 AS BalanceAmount,
    121741 AS BankAccountSeq,
    NOW(),
    tvib.DepositDueDate,
    NULL AS RemitDate,
    'VBS01',
    'VOC #2987 - Issue billing for negative amount' AS ControlRemark,
    90049 AS FirstInsertUno,
    NOW(),
    90049 AS LastUpdateUno,
    NOW(),
    NULL AS AdjustmentAmount
FROM temp_voc_issue_billing tvib
WHERE tvib.BillingNo IS NULL;

-- Step 4: Update temp table with BillingNo
UPDATE temp_voc_issue_billing tvib
JOIN PM_INVOICE_MASTER pim ON tvib.VendorCode = pim.TRADER_COMP_CODE
                           AND tvib.AppliedFromDate = pim.APPLIED_FROM_DATE
                           AND tvib.AppliedToDate = pim.APPLIED_TO_DATE
                           AND pim.FIRST_INSERT_UNO = 90049
                           AND pim.SALES_OR_VENDOR = 'V'
                           AND pim.BILLING_STATUS_CODE = 'VBS01'
SET tvib.BillingNo = pim.INVOICE_SEQ
WHERE tvib.BillingNo IS NULL;

-- Step 5: Insert PM_INVOICE_BOOKING_ITEM
INSERT INTO PM_INVOICE_BOOKING_ITEM (INVOICE_SEQ, BOOKING_ITEM_CODE, FIRST_INSERT_UNO, LAST_UPDATE_UNO)
SELECT 
    tvib.BillingNo,
    tvib.BookingItemCode,
    90049 AS FirstInsertUno,
    90049 AS LastUpdateUno
FROM temp_voc_issue_billing tvib 
WHERE tvib.BillingNo IS NOT NULL
ON DUPLICATE KEY UPDATE LAST_UPDATE_DATETIME = NOW();

-- Step 6: Update invoice amounts (will set negative amount -12,895 JPY)
UPDATE PM_INVOICE_MASTER
SET INVOICE_AMOUNT = IFNULL((
        SELECT SUM(VENDOR_SUM_AMOUNT) 
        FROM BK_BOOKING_HOTEL_ITEM
        JOIN PM_INVOICE_BOOKING_ITEM ON BK_BOOKING_HOTEL_ITEM.BOOKING_ITEM_CODE = PM_INVOICE_BOOKING_ITEM.BOOKING_ITEM_CODE
        WHERE PM_INVOICE_BOOKING_ITEM.INVOICE_SEQ = PM_INVOICE_MASTER.INVOICE_SEQ
    ), 0),
    BALANCE_AMOUNT = IFNULL((
        SELECT SUM(VENDOR_SUM_AMOUNT) 
        FROM BK_BOOKING_HOTEL_ITEM
        JOIN PM_INVOICE_BOOKING_ITEM ON BK_BOOKING_HOTEL_ITEM.BOOKING_ITEM_CODE = PM_INVOICE_BOOKING_ITEM.BOOKING_ITEM_CODE
        WHERE PM_INVOICE_BOOKING_ITEM.INVOICE_SEQ = PM_INVOICE_MASTER.INVOICE_SEQ
    ), 0),
    LAST_UPDATE_UNO = 90049,
    LAST_UPDATE_DATETIME = NOW()
WHERE PM_INVOICE_MASTER.SALES_OR_VENDOR = 'V'
  AND PM_INVOICE_MASTER.INVOICE_SEQ IN (SELECT tvib.BillingNo FROM temp_voc_issue_billing tvib WHERE tvib.BillingNo IS NOT NULL);

-- Step 7: Verify result
SELECT * FROM temp_voc_issue_billing tvib;

SELECT pim.INVOICE_SEQ, pim.INVOICE_AMOUNT, pim.BALANCE_AMOUNT, pim.BILLING_STATUS_CODE
FROM PM_INVOICE_MASTER pim
JOIN PM_INVOICE_BOOKING_ITEM pibi ON pim.INVOICE_SEQ = pibi.INVOICE_SEQ
WHERE pibi.BOOKING_ITEM_CODE = 'K26012111843H01';

Notes:

  • This booking has a negative amount (-12,895 JPY) which the system normally blocks
  • The SQL manually inserts the billing record, bypassing the UI validation
  • Bank Account Seq 121741 is used (the active account for vendor 601769)
  • Applied period: 2026-01-01 to 2026-01-31, Deposit due: 2026-02-28
Actions #4

Updated by Tom Dong about 1 month ago

  • Status changed from 진행(Doing) to QA test
  • Assignee changed from Tom Dong to Tracy Tran
  • % Done changed from 0 to 100
  • Build env. set to Prod

Billing no 761383

Actions #5

Updated by Tracy Tran about 1 month ago

checked

Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 50 MB)