หน้า 1 จากทั้งหมด 1

การ Set Payment Term

โพสต์แล้ว: พุธ 01 เม.ย. 2015 11:51 am
โดย Bhurivaj
ในกรณีที่ต้องการให้ตั้งการจ่ายเงินให้เป็น 50% แรกก่อนที่จะเริ่มทำงาน 7 วัน และ 50% หลังจากส่งมอบงานแล้ว มีวิธีการเซ็ตยังไงบ้างครับ

Re: การ Set Payment Term

โพสต์แล้ว: เสาร์ 04 เม.ย. 2015 6:38 pm
โดย kitcle
ในการใช้ Payment Term Advanced ในระบบบัญชี
ต้องมีการ customize เพิ่มโดยการ ต่อเติมคลาส account.payment.term และ account.payment.term.line
เมื่อจัดการในส่วน Model เรียบร้อยแล้ว
ไว้ผมจะมาจัดการในส่วนของ Views เพื่อแสดงผลต่อนะครับ ^_^

โค้ด: เลือกทั้งหมด

class account_payment_term(osv.osv):
    _inherit="account.payment.term"

    def compute(self, cr, uid, id, value, date_ref=False, context=None):

        if isinstance(id, list):
            id = id[0]
        if not date_ref:
            date_ref = datetime.now().strftime('%Y-%m-%d')
        pt = self.browse(cr, uid, id, context=context)
        amount = value
        result = []
        prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
        for line in pt.line_ids:
            if line.value == 'fixed':
                amt = round(line.value_amount, prec)
            elif line.value == 'procent':
                amt = round(value * line.value_amount, prec)
            elif line.value == 'balance':
                amt = round(amount, prec)
            elif line.value == 'division':
                amt = round(value / line.value_amount, prec)
            if amt:
                next_date = datetime.strptime(date_ref, '%Y-%m-%d')
                # Add months first
                next_date += relativedelta(months=line.months or 0)
                # Add days later
                next_date += relativedelta(days=line.days)
                if line.days2 < 0:
                    next_first_date = next_date + relativedelta(day=1,months=1) #Getting 1st of next month
                    next_date = next_first_date + relativedelta(days=line.days2)
                if line.days2 > 0:
                    next_date += relativedelta(day=line.days2, months=1)
                if line.exclude_month1 > 0:
                    if int(next_date.strftime('%m')) == line.exclude_month1:
                        next_date += relativedelta(months=1, day=line.exclude_day1)
                if line.exclude_month2 > 0:
                    if int(next_date.strftime('%m')) == line.exclude_month2:
                        next_date += relativedelta(months=1, day=line.exclude_day2)
                result.append( (next_date.strftime('%Y-%m-%d'), amt) )
                amount -= amt
        return result

account_payment_term()

class account_payment_term_line(osv.osv):
    _inherit = 'account.payment.term.line'

    _columns = {
        'months': fields.integer('Number of Months', help="Number of months to add to invoice date."),
        'exclude_month1': fields.integer('Trigger Month 1 ', help="First month to trigger the date."),
        'exclude_day1': fields.integer('Day 1 Default', help="Day of the next Month to set."),
        'exclude_month2': fields.integer('Trigger Month 2', help="Second month to trigger the date."),
        'exclude_day2': fields.integer('Day 2 Default', help="Day of the next Month to set."),
        'value': fields.selection([
            ('procent', 'Percent'),
            ('balance', 'Balance'),
            ('fixed', 'Fixed Amount'),
            ('division', 'Division'),
            ], 'Valuation', required=True, help="Select here the kind of valuation related to this payment term line. Note that you should have your last line with the type 'Balance' to ensure that the whole amount will be threated."),
        'value_amount': fields.float('Value Amount', digits=(12,4), help="For Value percent enter % ratio between 0-1."),
    }
account_payment_term_line()

Re: การ Set Payment Term

โพสต์แล้ว: อังคาร 07 เม.ย. 2015 10:00 am
โดย Bhurivaj
กำลังติดตามอยู่นะครับ ^ ^

Re: การ Set Payment Term

โพสต์แล้ว: อังคาร 07 เม.ย. 2015 7:56 pm
โดย naitae
ขอบคุณมากๆ ครับ สุดยอดมากครับ ขอติดตามนะครับ

Re: การ Set Payment Term

โพสต์แล้ว: จันทร์ 13 เม.ย. 2015 12:23 am
โดย sofe_000
โปรแกรม ไม่ต้องแก้เพิ่ม ก็ เปิด อินวอย เป็น เปอร์เช็นได้นะค่ะ