account
parent
e05909fe05
commit
3b6da8c247
|
@ -28,6 +28,7 @@
|
||||||
<field name="patient_type_id"/>
|
<field name="patient_type_id"/>
|
||||||
<field name="categ_id"/>
|
<field name="categ_id"/>
|
||||||
<field name="product_id" domain='[["categ_id","=",categ_id]]'/>
|
<field name="product_id" domain='[["categ_id","=",categ_id]]'/>
|
||||||
|
<field name="type"/>
|
||||||
<field name="ar_debit_id"/>
|
<field name="ar_debit_id"/>
|
||||||
<field name="ar_credit_id"/>
|
<field name="ar_credit_id"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -60,7 +60,8 @@
|
||||||
<field name="lines" count="3" nolabel="1">
|
<field name="lines" count="3" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="product_categ_id" onchange="onchange_line"/>
|
<field name="product_categ_id" onchange="onchange_line"/>
|
||||||
<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["code","like",parent.type_code]]' onchange="onchange_product"/>
|
<!--<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["code","like",parent.type_code]]' onchange="onchange_product"/>-->
|
||||||
|
<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["patient_types.id","=",parent.patient_type_id]]' onchange="onchange_product"/>
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
<field name="reimbursable" onchange="onchange_line"/>
|
<field name="reimbursable" onchange="onchange_line"/>
|
||||||
<field name="qty" onchange="onchange_line"/>
|
<field name="qty" onchange="onchange_line"/>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<inherit model="product" inherit="product_form">
|
||||||
|
<field name="categ_id" position="after">
|
||||||
|
<field name="patient_types"/>
|
||||||
|
</field>
|
||||||
|
</inherit>
|
|
@ -1,4 +1,4 @@
|
||||||
<inherit model="product.categ" inherit="product_list">
|
<inherit model="product" inherit="product_list">
|
||||||
<field name="brand_id" position="replace">
|
<field name="brand_id" position="replace">
|
||||||
<field name="categ_id"/>
|
<field name="categ_id"/>
|
||||||
<field name="can_sell"/>
|
<field name="can_sell"/>
|
||||||
|
|
|
@ -12,13 +12,9 @@
|
||||||
<field name="products" nolabel="1">
|
<field name="products" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="patient_type_id" onchange="onchange_ptype"/>
|
<field name="patient_type_id" onchange="onchange_ptype"/>
|
||||||
<field name="type_code" invisible="1" readonly="1"/>
|
|
||||||
<field name="product_categ_id"/>
|
<field name="product_categ_id"/>
|
||||||
<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["code","like",type_code]]' onchange="onchange_product"/>
|
<field name="product_id" domain='[["categ_id.id","=",product_categ_id],["patient_types.id","=",patient_type_id]]' onchange="onchange_product"/>
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
<!--<field name="account_id"/>-->
|
|
||||||
<!--<field name="ar_credit_id"/>-->
|
|
||||||
<!--<field name="ar_debit_id"/>-->
|
|
||||||
<field name="reimbursable"/>
|
<field name="reimbursable"/>
|
||||||
<field name="uom_id"/>
|
<field name="uom_id"/>
|
||||||
<field name="price" onchange="onchange_setting_line"/>
|
<field name="price" onchange="onchange_setting_line"/>
|
||||||
|
@ -28,6 +24,9 @@
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
|
<tab string="RD Shop">
|
||||||
|
<field name="shop_type_id"/>
|
||||||
|
</tab>
|
||||||
<tab string="Development">
|
<tab string="Development">
|
||||||
<button string="Click Me" type="default" method="run_script" perm="clinic_setting_test"/>
|
<button string="Click Me" type="default" method="run_script" perm="clinic_setting_test"/>
|
||||||
</tab>
|
</tab>
|
||||||
|
|
|
@ -42,7 +42,8 @@
|
||||||
</tabs>
|
</tabs>
|
||||||
</group>
|
</group>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Pay" method="pay" type="success"/>
|
<button string="Cash" method="pay_cash" type="success"/>
|
||||||
|
<button string="Credit" method="pay_credit" type="default"/>
|
||||||
</foot>
|
</foot>
|
||||||
<related>
|
<related>
|
||||||
<field name="invoices"/>
|
<field name="invoices"/>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import setting
|
from . import setting
|
||||||
from . import fin_setting
|
|
||||||
from . import setting_account_product
|
|
||||||
from . import setting_product
|
from . import setting_product
|
||||||
|
from . import setting_account_product
|
||||||
|
from . import setting_shop_product
|
||||||
from . import setting_level
|
from . import setting_level
|
||||||
from . import setting_policy
|
from . import setting_policy
|
||||||
|
from . import fin_setting
|
||||||
from . import cause_chronic
|
from . import cause_chronic
|
||||||
from . import comorbidity
|
from . import comorbidity
|
||||||
from . import department
|
from . import department
|
||||||
|
@ -98,3 +99,4 @@ from . import matching_payment
|
||||||
from . import shop
|
from . import shop
|
||||||
from . import shop_line
|
from . import shop_line
|
||||||
from . import sale_order
|
from . import sale_order
|
||||||
|
from . import product
|
||||||
|
|
|
@ -398,15 +398,12 @@ class HDCase(Model):
|
||||||
ar_debit_id=line.ar_debit_id.id
|
ar_debit_id=line.ar_debit_id.id
|
||||||
if not account_id or not ar_debit_id:
|
if not account_id or not ar_debit_id:
|
||||||
print("#2.find in ratchawat setting")
|
print("#2.find in ratchawat setting")
|
||||||
|
if line.reimbursable=='yes':
|
||||||
acc=prod_acc(prod.id,obj.patient_type_id.id)
|
acc=prod_acc(prod.id,obj.patient_type_id.id)
|
||||||
|
else:
|
||||||
|
acc=prod_acc(prod.id,obj.patient_type_id.id,'cash')
|
||||||
account_id=acc.get("ar_credit_id",None)
|
account_id=acc.get("ar_credit_id",None)
|
||||||
ar_debit_id=acc.get("ar_debit_id",None)
|
ar_debit_id=acc.get("ar_debit_id",None)
|
||||||
#print("#3.find account in account setting -> income account")
|
|
||||||
#if not account_id and not prod:
|
|
||||||
#account_id=setting.income_account_id.id
|
|
||||||
#print("#4.find in product(tab accounting)")
|
|
||||||
#if not account_id:
|
|
||||||
#account_id=prod.sale_account_id.id
|
|
||||||
if not account_id:
|
if not account_id:
|
||||||
raise Exception("No Income Credit Account for product [%s] %s"%(prod.code, prod.name))
|
raise Exception("No Income Credit Account for product [%s] %s"%(prod.code, prod.name))
|
||||||
if not ar_debit_id:
|
if not ar_debit_id:
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
|
||||||
|
class Product(Model):
|
||||||
|
_inherit="product"
|
||||||
|
_fields={
|
||||||
|
'patient_types': fields.Many2Many("clinic.patient.type","Patient Types"),
|
||||||
|
}
|
||||||
|
|
||||||
|
Product.register()
|
|
@ -13,6 +13,7 @@ class ClinicSetting(Model):
|
||||||
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
|
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
|
||||||
'products': fields.One2Many("clinic.setting.product","setting_id","Products"),
|
'products': fields.One2Many("clinic.setting.product","setting_id","Products"),
|
||||||
'account_products': fields.One2Many("clinic.setting.account.product","setting_id","Account Products"),
|
'account_products': fields.One2Many("clinic.setting.account.product","setting_id","Account Products"),
|
||||||
|
'shop_products': fields.One2Many("clinic.setting.shop.product","setting_id","Shop Products"),
|
||||||
'invoice_policies': fields.One2Many("clinic.setting.policy","setting_id","Invoice Policies"),
|
'invoice_policies': fields.One2Many("clinic.setting.policy","setting_id","Invoice Policies"),
|
||||||
'cost_per_case': fields.Float("Cost Per Case"),
|
'cost_per_case': fields.Float("Cost Per Case"),
|
||||||
'company_id': fields.Many2One("company", 'Company'),
|
'company_id': fields.Many2One("company", 'Company'),
|
||||||
|
@ -29,6 +30,7 @@ class ClinicSetting(Model):
|
||||||
'department_id': fields.Many2One("clinic.department","Department"),
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||||
'shop_categs': fields.Many2Many("product.categ","Categs"),
|
'shop_categs': fields.Many2Many("product.categ","Categs"),
|
||||||
|
'shop_type_id': fields.Many2One("clinic.patient.type","Patient Type"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
@ -73,9 +75,6 @@ class ClinicSetting(Model):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
path=context['path']
|
path=context['path']
|
||||||
line=get_data_path(data,path,parent=True)
|
line=get_data_path(data,path,parent=True)
|
||||||
ptype_id=line['patient_type_id']
|
|
||||||
ptype=get_model("clinic.patient.type").browse(ptype_id)
|
|
||||||
line['type_code']=ptype.code or ''
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_setting_line(self,context={}):
|
def onchange_setting_line(self,context={}):
|
||||||
|
@ -106,6 +105,35 @@ class ClinicSetting(Model):
|
||||||
if user_id !=1:
|
if user_id !=1:
|
||||||
print("Only admin!!")
|
print("Only admin!!")
|
||||||
return
|
return
|
||||||
|
obj=self.browse(1)
|
||||||
|
t={}
|
||||||
|
[t.update({x.code : x.id}) for x in get_model("clinic.patient.type").search_browse([])]
|
||||||
|
for prod in get_model("product").search_browse([]):
|
||||||
|
code=prod.code or ""
|
||||||
|
tcodes=code.split("-")
|
||||||
|
tids=[]
|
||||||
|
for tcode in tcodes:
|
||||||
|
tid=t.get(tcode,None)
|
||||||
|
if tid:
|
||||||
|
tids.append(tid)
|
||||||
|
|
||||||
|
prod.write({
|
||||||
|
'patient_types': [('add',tids)]
|
||||||
|
})
|
||||||
|
print("Done!")
|
||||||
|
return
|
||||||
|
|
||||||
|
for line in obj.account_products:
|
||||||
|
acc=line.ar_debit_id
|
||||||
|
type='credit'
|
||||||
|
if acc:
|
||||||
|
if acc.code=='101101':
|
||||||
|
type='cash'
|
||||||
|
line.write({
|
||||||
|
'type': type,
|
||||||
|
})
|
||||||
|
print("Done!")
|
||||||
|
return
|
||||||
for vs in get_model("clinic.visit").search_browse([['state','in', ['draft','pending']],['doctor_id','=',None]]):
|
for vs in get_model("clinic.visit").search_browse([['state','in', ['draft','pending']],['doctor_id','=',None]]):
|
||||||
doctor=vs.patient_id.doctor_id
|
doctor=vs.patient_id.doctor_id
|
||||||
if doctor:
|
if doctor:
|
||||||
|
@ -136,13 +164,13 @@ class ClinicSetting(Model):
|
||||||
print("to draft payment ", payment.id)
|
print("to draft payment ", payment.id)
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|
||||||
def get_product_account(self,ids,prod_id=None,patient_type_id=None,context={}):
|
def get_product_account(self,ids,prod_id=None,patient_type_id=None,pay_type='credit',context={}):
|
||||||
res={}
|
res={}
|
||||||
print("find ", prod_id, patient_type_id)
|
print("find ", prod_id, patient_type_id, pay_type)
|
||||||
for ac_prod in get_model("clinic.setting.account.product").search_browse([]):
|
dom=[['type','=',pay_type]]
|
||||||
|
for ac_prod in get_model("clinic.setting.account.product").search_browse(dom):
|
||||||
prod=ac_prod.product_id
|
prod=ac_prod.product_id
|
||||||
ptype=ac_prod.patient_type_id
|
ptype=ac_prod.patient_type_id
|
||||||
print(prod.id, ':: ', ptype.id)
|
|
||||||
if patient_type_id==ptype.id and prod_id==prod.id:
|
if patient_type_id==ptype.id and prod_id==prod.id:
|
||||||
print("found !")
|
print("found !")
|
||||||
res.update({
|
res.update({
|
||||||
|
|
|
@ -14,6 +14,7 @@ class SettingAccountProduct(Model):
|
||||||
"ar_credit_id": fields.Many2One("account.account","Income Credit",multi_company=True),
|
"ar_credit_id": fields.Many2One("account.account","Income Credit",multi_company=True),
|
||||||
"ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True),
|
"ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True),
|
||||||
'company_id': fields.Many2One("company","Company"),
|
'company_id': fields.Many2One("company","Company"),
|
||||||
|
"type": fields.Selection([("cash","Cash"),("credit","Credit")],"Type"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
|
class SettingShopProduct(Model):
|
||||||
|
_name="clinic.setting.shop.product"
|
||||||
|
_string="Setting Shop Product"
|
||||||
|
_multi_company=True
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
"setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"),
|
||||||
|
'categ_id': fields.Many2One("product.categ","Category"),
|
||||||
|
"product_id": fields.Many2One("product","Product"),
|
||||||
|
"ar_credit_id": fields.Many2One("account.account","Sale Account",multi_company=True),
|
||||||
|
"ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True),
|
||||||
|
'company_id': fields.Many2One("company","Company"),
|
||||||
|
}
|
||||||
|
|
||||||
|
_defaults={
|
||||||
|
"company_id": lambda *a: get_active_company(),
|
||||||
|
}
|
||||||
|
|
||||||
|
_order="categ_id"
|
||||||
|
|
||||||
|
SettingShopProduct.register()
|
|
@ -1,7 +1,7 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.access import get_active_user
|
from netforce.access import get_active_user, set_active_user
|
||||||
from netforce.utils import get_data_path
|
from netforce.utils import get_data_path
|
||||||
|
|
||||||
class Shop(Model):
|
class Shop(Model):
|
||||||
|
@ -72,6 +72,20 @@ class Shop(Model):
|
||||||
patient_id=hd_case.patient_id.id
|
patient_id=hd_case.patient_id.id
|
||||||
return patient_id
|
return patient_id
|
||||||
|
|
||||||
|
def _get_number(self,context={}):
|
||||||
|
while 1:
|
||||||
|
seq_id=get_model("sequence").find_sequence(name="Clinic RD Shop")
|
||||||
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
||||||
|
if not num:
|
||||||
|
return None
|
||||||
|
user_id=get_active_user()
|
||||||
|
set_active_user(1)
|
||||||
|
res=self.search([["number","=",num]])
|
||||||
|
set_active_user(user_id)
|
||||||
|
if not res:
|
||||||
|
return num
|
||||||
|
get_model("sequence").increment_number(seq_id,context=context)
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'number': '/',
|
'number': '/',
|
||||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||||
|
@ -142,13 +156,43 @@ class Shop(Model):
|
||||||
super().write(ids,vals,**kw)
|
super().write(ids,vals,**kw)
|
||||||
self.function_store(ids)
|
self.function_store(ids)
|
||||||
|
|
||||||
def pay(self,ids,context={}):
|
def pay_credit(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
active_id=obj.id
|
active_id=obj.id
|
||||||
action="clinic_shop"
|
action="clinic_shop"
|
||||||
if obj.related_id:
|
if obj.related_id:
|
||||||
active_id=obj.related_id.id
|
active_id=obj.related_id.id
|
||||||
action="clinic_hd_case"
|
action="clinic_hd_case"
|
||||||
|
st=get_model("clinic.setting").browse(1)
|
||||||
|
if not st.shop_type_id:
|
||||||
|
raise Exception("Please defind Shop Type on menu Clinic Settings -> RD Shop")
|
||||||
|
if obj.number=="/":
|
||||||
|
obj.write({
|
||||||
|
'number': self._get_number(),
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'name': action,
|
||||||
|
'mode': 'form',
|
||||||
|
'active_id': active_id,
|
||||||
|
},
|
||||||
|
'flash': 'Pay Successfully',
|
||||||
|
}
|
||||||
|
|
||||||
|
def pay_cash(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
active_id=obj.id
|
||||||
|
action="clinic_shop"
|
||||||
|
if obj.related_id:
|
||||||
|
active_id=obj.related_id.id
|
||||||
|
action="clinic_hd_case"
|
||||||
|
st=get_model("clinic.setting").browse(1)
|
||||||
|
if not st.shop_type_id:
|
||||||
|
raise Exception("Please defind Shop Type on menu Clinic Settings -> RD Shop")
|
||||||
|
if obj.number=="/":
|
||||||
|
obj.write({
|
||||||
|
'number': self._get_number()
|
||||||
|
})
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': action,
|
'name': action,
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ShopLine(Model):
|
||||||
'price': fields.Float("Price"),
|
'price': fields.Float("Price"),
|
||||||
'amount': fields.Float("Amount"),
|
'amount': fields.Float("Amount"),
|
||||||
'account_id': fields.Many2One("account.account","Account"),
|
'account_id': fields.Many2One("account.account","Account"),
|
||||||
|
'ar_debit_id': fields.Many2One("account.account","Account Debit"),
|
||||||
}
|
}
|
||||||
|
|
||||||
ShopLine.register()
|
ShopLine.register()
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
todo:
|
todo:
|
||||||
|
- sale medicine ***
|
||||||
|
- payment
|
||||||
|
- matching payment ***
|
||||||
|
- script generate hd case
|
||||||
- accounting
|
- accounting
|
||||||
- labor cost
|
- labor cost
|
||||||
- report ->ok
|
- report ->ok
|
||||||
|
@ -7,13 +11,10 @@ todo:
|
||||||
- doctor
|
- doctor
|
||||||
- total hd case
|
- total hd case
|
||||||
- invoice line -> account -> credit
|
- invoice line -> account -> credit
|
||||||
- debit from hd case setting
|
- if user select product by them self -> testing
|
||||||
- if user select product by them self
|
|
||||||
- credit <= product -> tab -> accounting -> sale -> sale account
|
- credit <= product -> tab -> accounting -> sale -> sale account
|
||||||
- debit <= 1. contact -> tab accounting -> account receiaveble , 2. finacial setting -> account receiable
|
- debit <= 1. contact -> tab accounting -> account receiaveble , 2. finacial setting -> account receiable
|
||||||
- sale medicine
|
|
||||||
- payment ***
|
|
||||||
- matching payment ***
|
|
||||||
|
|
||||||
|
|
||||||
- patient
|
- patient
|
||||||
|
|
Loading…
Reference in New Issue