示例#1
0
def create_journal_entry(title, remark, debit_account, credit_account, amount):
    customer_name = 'Customer Restaurant'
    doc_je = frappe.new_doc('Journal Entry')
    doc_je.title = title
    doc_je.voucher_type = 'Journal Entry'
    doc_je.naming_series = 'ACC-JV-.YYYY.-'
    doc_je.posting_date = get_last_audit_date()
    doc_je.company = frappe.get_doc('Global Defaults').default_company
    doc_je.total_amount_currency = frappe.get_doc(
        'Global Defaults').default_currency
    doc_je.remark = remark
    doc_je.user_remark = remark

    doc_jea_debit = frappe.new_doc('Journal Entry Account')
    doc_jea_debit.account = debit_account
    doc_jea_debit.debit = amount
    doc_jea_debit.debit_in_account_currency = amount
    doc_jea_debit.party_type = 'Customer'
    doc_jea_debit.party = customer_name
    doc_jea_debit.user_remark = remark

    doc_jea_credit = frappe.new_doc('Journal Entry Account')
    doc_jea_credit.account = credit_account
    doc_jea_credit.credit = amount
    doc_jea_credit.credit_in_account_currency = amount
    doc_jea_credit.party_type = 'Customer'
    doc_jea_credit.party = customer_name
    doc_jea_credit.user_remark = remark

    doc_je.append('accounts', doc_jea_debit)
    doc_je.append('accounts', doc_jea_credit)

    doc_je.save()
    doc_je.submit()
示例#2
0
def populate_tobe_posted():
    tobe_posted_list = []
    folio_list = frappe.get_all('Inn Folio',
                                filters={
                                    'status': 'Open',
                                    'type': 'Guest'
                                },
                                fields=['*'])
    for item in folio_list:
        reservation = frappe.get_doc('Inn Reservation', item.reservation_id)
        if reservation.status == 'In House' or reservation.status == 'Finish':
            room_charge_remark = 'Room Charge: Room Rate (Nett): ' + reservation.actual_room_id + " - " + \
                  get_last_audit_date().strftime("%d-%m-%Y")
            if not frappe.db.exists(
                    'Inn Folio Transaction', {
                        'parent': item.name,
                        'transaction_type': 'Room Charge',
                        'remark': room_charge_remark,
                        'is_void': 0
                    }):
                tobe_posted = frappe.new_doc('Inn Room Charge To Be Posted')
                tobe_posted.reservation_id = item.reservation_id
                tobe_posted.folio_id = item.name
                tobe_posted.room_id = reservation.actual_room_id
                tobe_posted.customer_id = reservation.customer_id
                tobe_posted.room_rate_id = reservation.room_rate
                tobe_posted.actual_room_rate = reservation.actual_room_rate
                tobe_posted_list.append(tobe_posted)
    return tobe_posted_list
示例#3
0
def is_there_closed_room_charge_posting_at():
    date = get_last_audit_date().strftime('%Y-%m-%d')

    if frappe.db.exists('Inn Room Charge Posting', {
            'audit_date': date,
            'status': 'Closed'
    }):
        return 1
    else:
        return 2
示例#4
0
def process_dayend_close(doc_id):
    need_resolve_flag = False
    # Create Journal Entry Pairing for Every Eligible Inn Folio Transactions
    folio_list = frappe.get_all('Inn Folio',
                                filters={
                                    'status': ['in', ['Open', 'Closed']],
                                    'journal_entry_id_closed': ['=', '']
                                })
    for item in folio_list:
        need_resolve_list = check_void_request(item.name)
        if len(need_resolve_list) > 0:
            need_resolve_flag = True

    if need_resolve_flag:
        return "There are transaction requested to be voided not yet responded. Please resolve the request first."
    else:
        print('Folio List Size: ', len(folio_list))
        for item in folio_list:
            print(datetime.datetime.now(), ': Folio ', item.name)
            doc_folio = frappe.get_doc('Inn Folio', item.name)
            if doc_folio.reservation_id:
                reservation = frappe.get_doc('Inn Reservation',
                                             doc_folio.reservation_id)

                if reservation.status == 'In House':
                    actual_room = frappe.get_doc('Inn Room',
                                                 reservation.actual_room_id)
                    actual_room.room_status = 'Occupied Dirty'
                    actual_room.save()

            trx_list = doc_folio.get('folio_transaction')
            for trx in trx_list:
                if trx.is_void == 0 and trx.journal_entry_id is None:
                    if trx.remark is None:
                        remark = trx.transaction_type + ' ' + trx.parent
                    elif trx.remark == '':
                        remark = trx.transaction_type + ' ' + trx.parent
                    else:
                        remark = trx.remark
                    customer_name = frappe.db.get_value(
                        'Inn Folio', trx.parent, 'customer_id')
                    doc_je = frappe.new_doc('Journal Entry')
                    doc_je.title = doc_folio.name
                    doc_je.voucher_type = 'Journal Entry'
                    doc_je.naming_series = 'ACC-JV-.YYYY.-'
                    doc_je.posting_date = get_last_audit_date()
                    doc_je.company = frappe.get_doc(
                        'Global Defaults').default_company
                    doc_je.total_amount_currency = frappe.get_doc(
                        'Global Defaults').default_currency
                    doc_je.remark = remark
                    doc_je.user_remark = remark

                    doc_jea_debit = frappe.new_doc('Journal Entry Account')
                    doc_jea_debit.account = trx.debit_account
                    doc_jea_debit.debit = trx.amount
                    doc_jea_debit.debit_in_account_currency = trx.amount
                    doc_jea_debit.party_type = 'Customer'
                    doc_jea_debit.party = customer_name
                    doc_jea_debit.user_remark = remark

                    doc_jea_credit = frappe.new_doc('Journal Entry Account')
                    doc_jea_credit.account = trx.credit_account
                    doc_jea_credit.credit = trx.amount
                    doc_jea_credit.credit_in_account_currency = trx.amount
                    doc_jea_credit.party_type = 'Customer'
                    doc_jea_credit.party = customer_name
                    doc_jea_credit.user_remark = remark

                    doc_je.append('accounts', doc_jea_debit)
                    doc_je.append('accounts', doc_jea_credit)

                    doc_je.save()
                    doc_je.submit()

                    trx.journal_entry_id = doc_je.name
                    trx.save()

        # Create Journal Entry Pairing for Every Eligible Inn Folio
        closed_folio_list = frappe.get_all('Inn Folio',
                                           filters={
                                               'status': 'Closed',
                                               'total_credit': ['!=', 0],
                                               'total_debit': ['!=', 0],
                                               'journal_entry_id_closed':
                                               ['=', '']
                                           })
        for item in closed_folio_list:
            doc_folio = frappe.get_doc('Inn Folio', item.name)
            cust_name = doc_folio.customer_id
            # Get all Closed folio with close date == last audit date
            if doc_folio.journal_entry_id_closed is None and doc_folio.close == get_last_audit_date(
            ):
                closed_folio_remark = 'Closed Folio Transaction'
                # Get all transactions that not void
                closed_trx_list = frappe.get_all('Inn Folio Transaction',
                                                 filters={
                                                     'parent': item.name,
                                                     'is_void': 0
                                                 },
                                                 fields=['*'])
                # Folio must not be empty, Because Journal Entry Table Account not allowed to be empty
                if len(closed_trx_list) > 0:
                    doc_je = frappe.new_doc('Journal Entry')
                    doc_je.title = doc_folio.name
                    doc_je.voucher_type = 'Journal Entry'
                    doc_je.naming_series = 'ACC-JV-.YYYY.-'
                    doc_je.posting_date = get_last_audit_date()
                    doc_je.company = frappe.get_doc(
                        'Global Defaults').default_company
                    doc_je.total_amount_currency = frappe.get_doc(
                        'Global Defaults').default_currency
                    doc_je.remark = closed_folio_remark
                    doc_je.user_remark = closed_folio_remark

                    for trx in closed_trx_list:
                        if trx.flag == 'Debit':
                            doc_jea_debit = frappe.new_doc(
                                'Journal Entry Account')
                            doc_jea_debit.account = trx.debit_account
                            doc_jea_debit.debit = trx.amount
                            doc_jea_debit.credit_in_account_currency = trx.amount  #amount flipped to credit
                            doc_jea_debit.party_type = 'Customer'
                            doc_jea_debit.party = cust_name
                            doc_jea_debit.user_remark = closed_folio_remark
                            doc_je.append('accounts', doc_jea_debit)
                        elif trx.flag == 'Credit':
                            doc_jea_credit = frappe.new_doc(
                                'Journal Entry Account')
                            doc_jea_credit.account = trx.credit_account
                            doc_jea_credit.credit = trx.amount
                            doc_jea_credit.debit_in_account_currency = trx.amount  #amount flipped to debit
                            doc_jea_credit.party_type = 'Customer'
                            doc_jea_credit.party = cust_name
                            doc_jea_credit.user_remark = closed_folio_remark
                            doc_je.append('accounts', doc_jea_credit)

                    doc_je.save()
                    doc_je.submit()
                    doc_folio.journal_entry_id_closed = doc_je.name
                    doc_folio.save()

        # Create Journal Entry for Inn Restaurant Finished Order
        # Get all finished order that not transfered to folio and not paired with journal entry yet
        order_list = frappe.get_all('Inn Restaurant Finished Order',
                                    filters={
                                        'transfer_charges_folio': ('=', ''),
                                        'is_journaled': 0,
                                    },
                                    fields=['*'])
        for order in order_list:
            restaurant_food = 0
            restaurant_beverage = 0
            restaurant_other = 0

            # 1. ORDER ITEM IN RESTAURANT FINISHED ORDER
            order_item_list = order.get('order_item')
            if order_item_list is not None and len(order_item_list) > 0:
                # Calculate Total Amount of Food, Beverages and Other Charges in Restaurant Order
                for item in order_item_list:
                    print('item now = ' + item.name)
                    menu_type = frappe.db.get_value('Inn Restaurant Menu Item',
                                                    item.item, 'item_type')
                    print('menu type = ' + menu_type)
                    if menu_type == 'Food':
                        restaurant_food += item.rate
                        print('restaurant_food now = ' + str(restaurant_food))
                    elif menu_type == 'Beverage':
                        restaurant_beverage += item.rate
                        print('restaurant_beverage now = ' +
                              str(restaurant_beverage))
                    elif menu_type == 'Other':
                        restaurant_other += item.rate
                        print('restaurant_other now = ' +
                              str(restaurant_other))

            # Create Journal Entry for Total Amount of Orders for Food, Beverages, and Other Restaurant charges
            if restaurant_food > 0:
                food_title = 'Restaurant Food of ' + order.name
                food_remark = 'Restaurant Food Charges from Restaurant Order: ' + order.name
                food_debit_account = frappe.get_doc(
                    'Inn Folio Transaction Type',
                    'Restaurant Food').debit_account
                food_credit_account = frappe.get_doc(
                    'Inn Folio Transaction Type',
                    'Restaurant Food').credit_account
                create_journal_entry(food_title, food_remark,
                                     food_debit_account, food_credit_account,
                                     restaurant_food)

            if restaurant_beverage > 0:
                bev_title = 'Restaurant Beverages of ' + order.name
                bev_remark = 'Restaurant Beverage Charges from Restaurant Order: ' + order.name
                bev_debit_account = frappe.get_doc(
                    'Inn Folio Transaction Type',
                    'Restaurant Beverages').debit_account
                bev_credit_account = frappe.get_doc(
                    'Inn Folio Transaction Type',
                    'Restaurant Beverages').credit_account
                create_journal_entry(bev_title, bev_remark, bev_debit_account,
                                     bev_credit_account, restaurant_beverage)
            if restaurant_other > 0:
                other_title = 'Restaurant Other of ' + order.name
                other_remark = 'Restaurant Other Charges from Restaurant Order: ' + order.name
                other_debit_account = frappe.get_doc(
                    'Inn Folio Transaction Type',
                    'Restaurant Other').debit_account
                other_credit_account = frappe.get_doc(
                    'Inn Folio Transaction Type',
                    'Restaurant Other').credit_account
                create_journal_entry(other_title, other_remark,
                                     other_debit_account, other_credit_account,
                                     restaurant_other)

            # Create Journal Entry for Round Off Charges
            ro_title = 'Round Off of ' + order.name
            ro_remark = 'Rounding off Amount of Restaurant Charges from Restaurant Order: ' + order.name
            ro_debit_account = frappe.get_doc('Inn Folio Transaction Type',
                                              'Round Off').debit_account
            ro_credit_account = frappe.get_doc('Inn Folio Transaction Type',
                                               'Round Off').credit_account
            create_journal_entry(ro_title, ro_remark, ro_debit_account,
                                 ro_credit_account, order.rounding_amount)
            # Create Journal Entry for Service
            service_title = 'FBS -- Service 10 % of ' + order.name
            service_remark = 'Service of Restaurant Charges from Restaurant Order: ' + order.name
            srv_debit_account = frappe.get_doc(
                'Inn Folio Transaction Type',
                'FBS -- Service 10 %').debit_account
            srv_credit_account = frappe.get_doc(
                'Inn Folio Transaction Type',
                'FBS -- Service 10 %').credit_account
            create_journal_entry(service_title, service_remark,
                                 srv_debit_account, srv_credit_account,
                                 order.service_amount)
            # Create Journal Entry for Tax
            tax_title = 'FBS -- Tax 11 %' + order.name
            tax_remark = 'Tax of Restaurant Charges from Restaurant Order: ' + order.name
            tax_debit_account = frappe.get_doc('Inn Folio Transaction Type',
                                               'FBS -- Tax 11 %').debit_account
            tax_credit_account = frappe.get_doc(
                'Inn Folio Transaction Type', 'FBS -- Tax 11 %').credit_account
            create_journal_entry(tax_title, tax_remark, tax_debit_account,
                                 tax_credit_account, order.tax_amount)

            # 2. ORDER PAYMENT IN RESTAURANT FINISHED ORDER
            order_payment_list = order.get('order_payment')
            if order_payment_list is not None and len(order_payment_list) > 0:
                for payment in order_payment_list:
                    payment_title = payment.mode_of_payment + ' Payment for ' + order.name
                    payment_remark = 'Payment with ' + payment.mode_of_payment + 'from Restaurant Order: ' + order.name
                    payment_debit_account = frappe.db.get_value(
                        'Mode of Payment Account', {
                            'parent':
                            payment.mode_of_payment,
                            'company':
                            frappe.get_doc("Global Defaults").default_company
                        }, "default_account")
                    payment_credit_account = frappe.db.get_list(
                        'Account', filters={'account_number':
                                            '2110.005'})[0].name
                    create_journal_entry(payment_title, payment_remark,
                                         payment_debit_account,
                                         payment_credit_account,
                                         payment.amount)

            # 3. SET VALUE IS_JOURNALED IN FINISHED ORDER TO TRUE, MARKING THAT THE ORDER ALREADY PAIRED WITH JOURNAL ENTRIES
            frappe.db.set_value('Inn Restaurant Finished Order', order.name,
                                'is_journaled', 1)

        doc_audit_log = frappe.new_doc('Inn Audit Log')
        doc_audit_log.naming_series = 'AL.DD.-.MM.-.YYYY.-'
        doc_audit_log.audit_date = get_last_audit_date() + datetime.timedelta(
            days=1)
        doc_audit_log.posting_date = datetime.datetime.now()
        doc_audit_log.posted_by = frappe.session.user
        doc_audit_log.insert()

        doc = frappe.get_doc('Inn Dayend Close', doc_id)
        doc.status = 'Closed'
        doc.save()

        return doc.status
示例#5
0
def post_individual_room_charges(parent_id, tobe_posted_list):
    return_value = ''
    room_charge_posting_doc = frappe.get_doc('Inn Room Charge Posting',
                                             parent_id)
    list_json = json.loads(tobe_posted_list)
    for item in list_json:
        # Create Inn Folio Transaction Bundle
        ftb_doc = frappe.new_doc('Inn Folio Transaction Bundle')
        ftb_doc.transaction_type = 'Room Charge'
        ftb_doc.insert()

        # Posting Room Charge
        item_doc = frappe.get_doc('Inn Room Charge To Be Posted', item)
        accumulated_amount = 0.00
        room_charge_debit_account, room_charge_credit_account = get_accounts_from_id(
            'Room Charge')
        reservation = frappe.get_doc('Inn Reservation',
                                     item_doc.reservation_id)
        room_charge_folio_trx = frappe.new_doc('Inn Folio Transaction')
        room_charge_folio_trx.flag = 'Debit'
        room_charge_folio_trx.is_void = 0
        room_charge_folio_trx.idx = get_idx(item_doc.folio_id)
        room_charge_folio_trx.transaction_type = 'Room Charge'
        room_charge_folio_trx.amount = float(
            int(reservation.nett_actual_room_rate))
        accumulated_amount += float(int(reservation.nett_actual_room_rate))
        room_charge_folio_trx.debit_account = room_charge_debit_account
        room_charge_folio_trx.credit_account = room_charge_credit_account
        room_charge_folio_trx.remark = 'Room Charge: Room Rate (Nett): ' + item_doc.room_id + " - " + get_last_audit_date(
        ).strftime("%d-%m-%Y")
        room_charge_folio_trx.parent = item_doc.folio_id
        room_charge_folio_trx.parenttype = 'Inn Folio'
        room_charge_folio_trx.parentfield = 'folio_transaction'
        room_charge_folio_trx.ftb_id = ftb_doc.name
        room_charge_folio_trx.insert()

        return_value = return_value + '<li>' + room_charge_folio_trx.remark + '</li>'

        # Create Inn Folio Transaction Bundle Detail Item Room Charge
        ftbd_doc = frappe.new_doc('Inn Folio Transaction Bundle Detail')
        ftbd_doc.transaction_type = room_charge_folio_trx.transaction_type
        ftbd_doc.transaction_id = room_charge_folio_trx.name
        ftb_doc.append('transaction_detail', ftbd_doc)

        # Posting Room Charge Tax/Service
        room_tb_id, room_tb_amount, _ = calculate_inn_tax_and_charges(
            reservation.nett_actual_room_rate,
            reservation.actual_room_rate_tax)
        for index, room_tax_item_name in enumerate(room_tb_id):
            room_tax_doc = frappe.new_doc('Inn Folio Transaction')
            room_tax_doc.flag = 'Debit'
            room_tax_doc.is_void = 0
            room_tax_doc.idx = get_idx(item_doc.folio_id)
            room_tax_doc.transaction_type = 'Room Charge Tax/Service'
            room_tax_doc.amount = room_tb_amount[index]
            accumulated_amount += room_tb_amount[index]
            room_tax_doc.credit_account = frappe.get_doc(
                'Inn Tax Breakdown', room_tax_item_name).breakdown_account
            room_tax_doc.debit_account = room_charge_debit_account
            room_tax_doc.remark = 'Room Charge Tax Room Rate ' + room_tax_item_name + ' : ' + item_doc.room_id + " - " + get_last_audit_date(
            ).strftime("%d-%m-%Y")
            room_tax_doc.parent = item_doc.folio_id
            room_tax_doc.parenttype = 'Inn Folio'
            room_tax_doc.parentfield = 'folio_transaction'
            room_tax_doc.ftb_id = ftb_doc.name
            room_tax_doc.insert()

            # Create Inn Folio Transaction Bundle Detail Item Room Charge Tax/Service
            ftbd_doc = frappe.new_doc('Inn Folio Transaction Bundle Detail')
            ftbd_doc.transaction_type = room_tax_doc.transaction_type
            ftbd_doc.transaction_id = room_tax_doc.name
            ftb_doc.append('transaction_detail', ftbd_doc)

        # Posting Breakfast Charge
        breakfast_charge_debit_account, breakfast_charge_credit_account = get_accounts_from_id(
            'Breakfast Charge')
        breakfast_charge_folio_trx = frappe.new_doc('Inn Folio Transaction')
        breakfast_charge_folio_trx.flag = 'Debit'
        breakfast_charge_folio_trx.is_void = 0
        breakfast_charge_folio_trx.idx = get_idx(item_doc.folio_id)
        breakfast_charge_folio_trx.transaction_type = 'Breakfast Charge'
        breakfast_charge_folio_trx.amount = float(
            int(reservation.nett_actual_breakfast_rate))
        accumulated_amount += float(int(
            reservation.nett_actual_breakfast_rate))
        breakfast_charge_folio_trx.debit_account = breakfast_charge_debit_account
        breakfast_charge_folio_trx.credit_account = breakfast_charge_credit_account
        breakfast_charge_folio_trx.remark = 'Room Charge: Breakfast (Nett): ' + item_doc.room_id + " - " + get_last_audit_date(
        ).strftime("%d-%m-%Y")
        breakfast_charge_folio_trx.parent = item_doc.folio_id
        breakfast_charge_folio_trx.parenttype = 'Inn Folio'
        breakfast_charge_folio_trx.parentfield = 'folio_transaction'
        breakfast_charge_folio_trx.ftb_id = ftb_doc.name
        breakfast_charge_folio_trx.insert()

        # Create Inn Folio Transaction Bundle Detail Item Breakfast Charge
        ftbd_doc = frappe.new_doc('Inn Folio Transaction Bundle Detail')
        ftbd_doc.transaction_type = breakfast_charge_folio_trx.transaction_type
        ftbd_doc.transaction_id = breakfast_charge_folio_trx.name
        ftb_doc.append('transaction_detail', ftbd_doc)

        # Posting Breakfast Tax/Service
        breakfast_tb_id, breakfast_tb_amount, _ = calculate_inn_tax_and_charges(
            reservation.nett_actual_breakfast_rate,
            reservation.actual_breakfast_rate_tax)
        for index, breakfast_tax_item_name in enumerate(breakfast_tb_id):
            breakfast_tax_doc = frappe.new_doc('Inn Folio Transaction')
            breakfast_tax_doc.flag = 'Debit'
            breakfast_tax_doc.is_void = 0
            breakfast_tax_doc.idx = get_idx(item_doc.folio_id)
            breakfast_tax_doc.transaction_type = 'Breakfast Charge Tax/Service'
            breakfast_tax_doc.amount = breakfast_tb_amount[index]
            accumulated_amount += breakfast_tb_amount[index]
            breakfast_tax_doc.credit_account = frappe.get_doc(
                'Inn Tax Breakdown', breakfast_tax_item_name).breakdown_account
            breakfast_tax_doc.debit_account = breakfast_charge_debit_account
            breakfast_tax_doc.remark = 'Breakfast Charge Tax Room Rate ' + breakfast_tax_item_name + ' : ' + item_doc.room_id + " - " + get_last_audit_date(
            ).strftime("%d-%m-%Y")
            breakfast_tax_doc.parent = item_doc.folio_id
            breakfast_tax_doc.parenttype = 'Inn Folio'
            breakfast_tax_doc.parentfield = 'folio_transaction'
            breakfast_tax_doc.ftb_id = ftb_doc.name
            breakfast_tax_doc.insert()

            # Create Inn Folio Transaction Bundle Detail Item Breakfast Charge Tax/Service
            ftbd_doc = frappe.new_doc('Inn Folio Transaction Bundle Detail')
            ftbd_doc.transaction_type = breakfast_tax_doc.transaction_type
            ftbd_doc.transaction_id = breakfast_tax_doc.name
            ftb_doc.append('transaction_detail', ftbd_doc)

        print("accumulated amount = " + str(accumulated_amount))
        print("math_ceil(accumulated amount) = " +
              str(math.ceil(accumulated_amount)))
        print("actual room rate = " + str(reservation.actual_room_rate))
        print("abs = " + str(
            abs(
                math.ceil(accumulated_amount) -
                int(reservation.actual_room_rate))))
        if abs(
                math.ceil(accumulated_amount) -
                int(reservation.actual_room_rate)) != 0:
            difference = math.ceil(accumulated_amount) - int(
                reservation.actual_room_rate)
            if difference > 0:
                last_adjusted = 'breakfast'
                adjusted_room_charge_amount = room_charge_folio_trx.amount
                adjusted_breakfast_charge_amount = breakfast_charge_folio_trx.amount
                for i in range(0, abs(difference)):
                    if last_adjusted == 'room':
                        adjusted_room_charge_amount = adjusted_room_charge_amount - 1.0
                        last_adjusted = 'breakfast'
                    else:
                        adjusted_breakfast_charge_amount = adjusted_breakfast_charge_amount - 1.0
                        last_adjusted = 'room'
            elif difference < 0:
                last_adjusted = 'room'
                adjusted_room_charge_amount = room_charge_folio_trx.amount
                adjusted_breakfast_charge_amount = breakfast_charge_folio_trx.amount
                for i in range(0, abs(difference)):
                    if last_adjusted == 'room':
                        adjusted_room_charge_amount = adjusted_room_charge_amount + 1.0
                        last_adjusted = 'breakfast'
                    else:
                        adjusted_breakfast_charge_amount = adjusted_breakfast_charge_amount + 1.0
                        last_adjusted = 'room'

            room_charge_folio_trx.amount = adjusted_room_charge_amount
            room_charge_folio_trx.save()
            breakfast_charge_folio_trx.amount = adjusted_breakfast_charge_amount
            breakfast_charge_folio_trx.save()

        # Resave Bundle to save Detail
        ftb_doc.save()

        posted = frappe.new_doc('Inn Room Charge Posted')
        posted.reservation_id = item_doc.reservation_id
        posted.folio_id = item_doc.folio_id
        posted.room_id = item_doc.room_id
        posted.customer_id = item_doc.customer_id
        posted.room_rate_id = item_doc.room_rate_id
        posted.actual_room_rate = item_doc.actual_room_rate
        posted.folio_transaction_id = room_charge_folio_trx.name
        posted.parent = parent_id
        posted.parentfield = 'already_posted'
        posted.parenttype = 'Inn Room Charge Posting'
        room_charge_posting_doc.append('already_posted', posted)

        frappe.delete_doc('Inn Room Charge To Be Posted', item_doc.name)

    room_charge_posting_doc.save()
    calculate_already_posted_total(room_charge_posting_doc.name)
    return return_value
示例#6
0
def add_audit_date(doc, method):
	if doc.audit_date:
		pass
	else:
		audit_date = get_last_audit_date()
		doc.audit_date = audit_date