rematching 40%
							parent
							
								
									502020a8d3
								
							
						
					
					
						commit
						6c9f041771
					
				| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					<action>                                                                                                         
 | 
				
			||||||
 | 
					    <field name="string">Payment Matching</field>
 | 
				
			||||||
 | 
					    <field name="view_cls">report</field>                                                                        
 | 
				
			||||||
 | 
					    <field name="model">clinic.payment.matching</field>
 | 
				
			||||||
 | 
					    <field name="report_template">payment_matching</field>                                                      
 | 
				
			||||||
 | 
					    <field name="report_template_xls">payment_matching</field>                                                         
 | 
				
			||||||
 | 
					    <field name="menu">account_menu</field>                                                                  
 | 
				
			||||||
 | 
					</action>  
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
<inherit inherit="account_menu">
 | 
					<inherit inherit="account_menu">
 | 
				
			||||||
    <item string="Settings" position="before">
 | 
					    <item string="Settings" position="before">
 | 
				
			||||||
        <item string="Ratchawat Clinic">
 | 
					        <item string="Ratchawat">
 | 
				
			||||||
            <item string="Account Product" action="clinic_setting_account_product"/>
 | 
					            <item string="Account Product" action="clinic_setting_account_product"/>
 | 
				
			||||||
            <item string="Account Patient" action="clinic_setting_account_patient"/>
 | 
					            <item string="Account Patient" action="clinic_setting_account_patient"/>
 | 
				
			||||||
            <item string="HD Case Expense" action="clinic_report_account_hd_case_summary"/>
 | 
					            <item string="HD Case Expense" action="clinic_report_account_hd_case_summary"/>
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,9 @@
 | 
				
			||||||
            <item string="Labor Cost Daily" action="clinic_report_labor_cost_daily"/>
 | 
					            <item string="Labor Cost Daily" action="clinic_report_labor_cost_daily"/>
 | 
				
			||||||
            <item string="Labor Cost Overtime" action="clinic_report_labor_cost_overtime"/>
 | 
					            <item string="Labor Cost Overtime" action="clinic_report_labor_cost_overtime"/>
 | 
				
			||||||
        </item>
 | 
					        </item>
 | 
				
			||||||
 | 
					        <item string="Matching">
 | 
				
			||||||
 | 
					            <item string="Payment Matching" action="clinic_payment_matching"/>
 | 
				
			||||||
 | 
					        </item>
 | 
				
			||||||
    </item>
 | 
					    </item>
 | 
				
			||||||
    <item string="Financial Settings" position="after">
 | 
					    <item string="Financial Settings" position="after">
 | 
				
			||||||
            <item string="Ratchawat Settings" action="clinic_account_setting"/>
 | 
					            <item string="Ratchawat Settings" action="clinic_account_setting"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,5 @@
 | 
				
			||||||
 | 
					<inherit inherit="doc_form">
 | 
				
			||||||
 | 
					    <field name="partner_id" position="before">
 | 
				
			||||||
 | 
					        <field name="name"/>
 | 
				
			||||||
 | 
					    </field>
 | 
				
			||||||
 | 
					</inherit>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,15 @@
 | 
				
			||||||
 | 
					<form model="clinic.payment.matching">
 | 
				
			||||||
 | 
					    <!--<field name="date" span="2" mode="month"/>-->
 | 
				
			||||||
 | 
					    <group form_layout="stacked">
 | 
				
			||||||
 | 
					        <separator string="Invoice Filter"/>
 | 
				
			||||||
 | 
					        <field name="period_id" onchange="onchange_period" domain='[["state","=","open"]]' span="2"/>
 | 
				
			||||||
 | 
					        <field name="date_from" span="2"/>
 | 
				
			||||||
 | 
					        <field name="date_to" span="2"/>
 | 
				
			||||||
 | 
					        <field name="inv_state" span="2"/>
 | 
				
			||||||
 | 
					        <field name="branch_id" span="2"/>
 | 
				
			||||||
 | 
					        <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
 | 
				
			||||||
 | 
					    </group>
 | 
				
			||||||
 | 
					    <separator string="Document Mathing"/>
 | 
				
			||||||
 | 
					    <field name="file_id" span="2"/>
 | 
				
			||||||
 | 
					    <field name="view_type" span="2"/>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
<inherit model="product" inherit="product_form">
 | 
					<inherit model="product" inherit="product_form">
 | 
				
			||||||
    <tab string="Other" position="after">
 | 
					    <tab string="Other" position="after">
 | 
				
			||||||
        <tab string="Ratchawat Clinic">
 | 
					        <tab string="Ratchawat">
 | 
				
			||||||
            <group form_layout="stacked">
 | 
					            <group form_layout="stacked">
 | 
				
			||||||
                <separator string="View Product"/>
 | 
					                <separator string="Product View"/>
 | 
				
			||||||
                <field name="patient_types" nolabel="1" span="12">
 | 
					                <field name="patient_types" nolabel="1" span="12">
 | 
				
			||||||
                    <list>
 | 
					                    <list>
 | 
				
			||||||
                        <field name="code"/>
 | 
					                        <field name="code"/>
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@
 | 
				
			||||||
                        <field name="default"/>
 | 
					                        <field name="default"/>
 | 
				
			||||||
                    </list>
 | 
					                    </list>
 | 
				
			||||||
                </field>
 | 
					                </field>
 | 
				
			||||||
                <separator string="Account Product Setting"/>
 | 
					                <separator string="Product Account Setting"/>
 | 
				
			||||||
                <field name="account_products" nolabel="1">
 | 
					                <field name="account_products" nolabel="1">
 | 
				
			||||||
                    <list>
 | 
					                    <list>
 | 
				
			||||||
                        <field name="patient_type_id"/>
 | 
					                        <field name="patient_type_id"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,3 +142,5 @@ from . import conv_bal
 | 
				
			||||||
from . import conv_sale_invoice
 | 
					from . import conv_sale_invoice
 | 
				
			||||||
from . import account_move_line
 | 
					from . import account_move_line
 | 
				
			||||||
from . import invoice_payment
 | 
					from . import invoice_payment
 | 
				
			||||||
 | 
					from . import document
 | 
				
			||||||
 | 
					from . import payment_matching
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					from netforce.model import Model,fields
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Document(Model):
 | 
				
			||||||
 | 
					    _inherit="document"
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    _fields={
 | 
				
			||||||
 | 
					        'name': fields.Char("Name",search=True),
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Document.register()
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,108 @@
 | 
				
			||||||
 | 
					import time
 | 
				
			||||||
 | 
					from calendar import monthrange
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from netforce.model import Model, fields, get_model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class PaymentMatching(Model):
 | 
				
			||||||
 | 
					    _name="clinic.payment.matching"
 | 
				
			||||||
 | 
					    _string="Payment Matching"
 | 
				
			||||||
 | 
					    _transient=True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _fields={
 | 
				
			||||||
 | 
					        'name': fields.Char("Name"),
 | 
				
			||||||
 | 
					        "date": fields.Date("Month"),
 | 
				
			||||||
 | 
					        "date_from": fields.Date("From", required=True),
 | 
				
			||||||
 | 
					        "date_to": fields.Date("To", required=True),
 | 
				
			||||||
 | 
					        'file_id': fields.Many2One('document','File',domain=[['categ_id.code','=','MP']]),
 | 
				
			||||||
 | 
					        "period_id": fields.Many2One("clinic.period.line","Period"),
 | 
				
			||||||
 | 
					        'department_id': fields.Many2One("clinic.department","Department"),
 | 
				
			||||||
 | 
					        'branch_id': fields.Many2One("clinic.branch","Branch"),
 | 
				
			||||||
 | 
					        "inv_state": fields.Selection([("draft","Draft"),("waiting_approval","Waiting Approval"),("waiting_payment","Waiting Payment"),("paid","Paid"),("voided","Voided")],"Status"),
 | 
				
			||||||
 | 
					        "view_type": fields.Selection([("invoice","Invoice"),("file","File")],"View Type"),
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _get_date_from(self,context={}):
 | 
				
			||||||
 | 
					        year,month,day=time.strftime("%Y-%m-%d").split("-")
 | 
				
			||||||
 | 
					        return '%s-%s-%s'%(year,month,day)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _get_date_to(self,context={}):
 | 
				
			||||||
 | 
					        year,month,day=time.strftime("%Y-%m-%d").split("-")
 | 
				
			||||||
 | 
					        weekday, total_day=monthrange(int(year), int(month))
 | 
				
			||||||
 | 
					        return "%s-%s-%s"%(year,month,day)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def default_get(self,field_names=None,context={},**kw):
 | 
				
			||||||
 | 
					        defaults=context.get("defaults",{})
 | 
				
			||||||
 | 
					        date_from=defaults.get("date_from", self._get_date_from())
 | 
				
			||||||
 | 
					        date_to=defaults.get("date_to", self._get_date_to())
 | 
				
			||||||
 | 
					        yearnow=date_from.split("-")[0]
 | 
				
			||||||
 | 
					        for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
 | 
				
			||||||
 | 
					            for line in period.lines:
 | 
				
			||||||
 | 
					                if line.state=='open':
 | 
				
			||||||
 | 
					                    period_id=line.id
 | 
				
			||||||
 | 
					                    date_from=line.date_start
 | 
				
			||||||
 | 
					                    date_to=line.date_stop
 | 
				
			||||||
 | 
					                    break
 | 
				
			||||||
 | 
					        res={
 | 
				
			||||||
 | 
					            'period_id': period_id,
 | 
				
			||||||
 | 
					            'date': time.strftime("%Y-%m-%d"),
 | 
				
			||||||
 | 
					            'date_from': date_from,
 | 
				
			||||||
 | 
					            'date_to': date_to,
 | 
				
			||||||
 | 
					            'inv_state': 'waiting_payment',
 | 
				
			||||||
 | 
					            'view_type': 'invoice',
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def onchange_period(self,context={}):   
 | 
				
			||||||
 | 
					        data=context['data']
 | 
				
			||||||
 | 
					        period_id=data['period_id']
 | 
				
			||||||
 | 
					        period=get_model('clinic.period.line').browse(period_id)
 | 
				
			||||||
 | 
					        data['date_from']=period.date_start
 | 
				
			||||||
 | 
					        data['date_to']=period.date_stop
 | 
				
			||||||
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_report_data(self,ids,context={}):
 | 
				
			||||||
 | 
					        defaults=self.default_get(context=context)
 | 
				
			||||||
 | 
					        print('defaults ', defaults)
 | 
				
			||||||
 | 
					        date_from=defaults.get('date_from')
 | 
				
			||||||
 | 
					        date_to=defaults.get('date_to')
 | 
				
			||||||
 | 
					        branch_id=None
 | 
				
			||||||
 | 
					        department_id=None
 | 
				
			||||||
 | 
					        inv_state=defaults.get('inv_state')
 | 
				
			||||||
 | 
					        view_type=defaults.get('view_type')
 | 
				
			||||||
 | 
					        if ids:
 | 
				
			||||||
 | 
					            obj=self.browse(ids)[0]
 | 
				
			||||||
 | 
					            date_from=obj.date_from
 | 
				
			||||||
 | 
					            date_to=obj.date_to
 | 
				
			||||||
 | 
					            branch_id=obj.branch_id.id
 | 
				
			||||||
 | 
					            department_id=obj.department_id.id
 | 
				
			||||||
 | 
					            inv_state=obj.inv_state
 | 
				
			||||||
 | 
					            view_type=obj.view_type
 | 
				
			||||||
 | 
					        lines=[]
 | 
				
			||||||
 | 
					        dom=[
 | 
				
			||||||
 | 
					            ['date','>=',date_from],
 | 
				
			||||||
 | 
					            ['date','<=',date_to],
 | 
				
			||||||
 | 
					            ['state','=',inv_state],
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					        if branch_id and not department_id:
 | 
				
			||||||
 | 
					            dom.append(['department_id.branch_id','=',branch_id])
 | 
				
			||||||
 | 
					        elif department_id:
 | 
				
			||||||
 | 
					            dom.append(['department_id','=',department_id])
 | 
				
			||||||
 | 
					        if view_type=='invoice':            
 | 
				
			||||||
 | 
					            field_names=['date','number','amount_due']
 | 
				
			||||||
 | 
					            for inv in get_model('account.invoice').search_read(dom,field_names):
 | 
				
			||||||
 | 
					                vals={}
 | 
				
			||||||
 | 
					                for field_name in field_names:
 | 
				
			||||||
 | 
					                    vals[field_name]=inv[field_name],
 | 
				
			||||||
 | 
					                lines.append(vals)
 | 
				
			||||||
 | 
					        data={
 | 
				
			||||||
 | 
					            'lines': lines,
 | 
				
			||||||
 | 
					            'date_from': date_from,
 | 
				
			||||||
 | 
					            'date_to': date_to,
 | 
				
			||||||
 | 
					            'total_inv': len(lines),
 | 
				
			||||||
 | 
					            'view_type': view_type,
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PaymentMatching.register()
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
- location
 | 
					mathching payment:
 | 
				
			||||||
    - staff
 | 
					    target
 | 
				
			||||||
    - patient
 | 
					        get invoice all invoice
 | 
				
			||||||
 | 
					    can match any
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -0,0 +1,38 @@
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
					<center>
 | 
				
			||||||
 | 
					    <h3>Payment Matching</h3>
 | 
				
			||||||
 | 
					    <h4>From {{date_from}} To {{date_to}}</h4>
 | 
				
			||||||
 | 
					</center>
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<div class="row">
 | 
				
			||||||
 | 
					    <div class="col-sm-6">
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div class="col-sm-6">
 | 
				
			||||||
 | 
					        <h4>
 | 
				
			||||||
 | 
					            <span class="pull-right label label-default">TOTAL: {{total_inv}}</span>
 | 
				
			||||||
 | 
					        </h4>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					<table class="table table-hover">
 | 
				
			||||||
 | 
					    {{#ifeq view_type 'invoice'}}
 | 
				
			||||||
 | 
					        <thead>
 | 
				
			||||||
 | 
					            <th>Invoice Date</th>
 | 
				
			||||||
 | 
					            <th>Number</th>
 | 
				
			||||||
 | 
					        </thead>
 | 
				
			||||||
 | 
					        <tbody>
 | 
				
			||||||
 | 
					            {{#if lines}}
 | 
				
			||||||
 | 
					                {{#each lines}}
 | 
				
			||||||
 | 
					                    <tr>
 | 
				
			||||||
 | 
					                        <td>{{date}}</td>
 | 
				
			||||||
 | 
					                        <td>{{number}}</td>
 | 
				
			||||||
 | 
					                    </tr>
 | 
				
			||||||
 | 
					                {{/each}}
 | 
				
			||||||
 | 
					            {{else}}
 | 
				
			||||||
 | 
					            {{/if}}
 | 
				
			||||||
 | 
					        </tbody>
 | 
				
			||||||
 | 
					        <tfoot>
 | 
				
			||||||
 | 
					        </tfoot>
 | 
				
			||||||
 | 
					    {{else}}
 | 
				
			||||||
 | 
					        TODO
 | 
				
			||||||
 | 
					    {{/ifeq}}
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
		Loading…
	
		Reference in New Issue