How to manage petty expenses on ERPNext?

Is there any module to record the petty expenses on ERPNext. In purchase module we create Material request and then create PO to procure materials but we cannot follow the process for daily repair and maintenance items: puncture, food expenses, electric wiring repair etc. where to record such expenses?

You mean like this- Autosum for Cashbook

Yes similar to this

You need to make a new Doctype name Petty cash or cashbook, and then make a child table for the entries.

Here is the mine.

Main

Then make the child table and link with the doctype
Child Table

Final Results

Hope it works !

1 Like

Thanks for sharing. I will try this.

You’re welcome.

If it works don’t forget to mark the solution :slight_smile:

Thanks

Before starting this I want to ask one thing. Do we need to add new entry for every day and submit it? Also please clear is it linked to accounts heads?

Yes, you need to create each entry individually. For my setup, I created a workflow:

  1. I assigned a role to the Site Supervisor, who creates these entries daily.
  2. At the end of the month, the Site Supervisor submits the CashBook, allowing the Project Head to approve the entries.

Once the document is submitted for the next workflow state, it will automatically restrict editing access for the Site Supervisor.

And yes it’s linked if you face issue you can link it

Thanks

Hello, I have customised a new doctype as Petty Expenses. I have doubt in some fields. Can u please mention the field type for fund input, expense, Net monthly expense and closing balance fields. Also please share if they are linked with any other doctype?

Here:-
For any amount entry → Float


how to automsum in net monthly expense and closing balance.

Add a client script

   frappe.ui.form.on('Cash Book', {
 	opening_balance: function(frm) {
    if(frm.doc.closing_balance == 0){
        frm.doc.closing_balance = frm.doc.opening_balance
   }else{
       var fundInp = 0
        var expInp = 0
        var CloseBal = 0
        $.each(frm.doc.data_aez3i,  function(i,  d) {
            fundInp += d.fund_input
            expInp += d.expense
            CloseBal = frm.doc.opening_balance + fundInp - expInp
        });
        frm.doc.closing_balance = CloseBal;

   }

    refresh_field("closing_balance")
},


before_save: function(frm) {
    var fundInp = 0
    var expInp = 0
    var CloseBal = 0
    $.each(frm.doc.data_aez3i,  function(i,  d) {
            fundInp += d.fund_input
            expInp += d.expense
            CloseBal = frm.doc.opening_balance + fundInp - expInp
        });
        frm.doc.closing_balance = CloseBal;
        frm.doc.net_monthly_expense  = expInp
    frm.refresh("")
}
})



frappe.ui.form.on('Cash Book Child', {
fund_input: function(frm, cdt, cdn) {
    // var d = locals[cdt][cdn];
    // var fundInp = 0
    // var CloseBal = 0
    // frm.doc.closing_balance += d.fund_input
   
    // refresh_field("closing_balance")
    
     var fundInp = 0
    var expInp = 0
    var CloseBal = 0
    $.each(frm.doc.data_aez3i,  function(i,  d) {
            fundInp += d.fund_input
            expInp += d.expense
            CloseBal = frm.doc.opening_balance + fundInp - expInp
        });
        frm.doc.closing_balance = CloseBal;
        frm.doc.net_monthly_expense  = expInp
    frm.refresh("")

  },

   expense: function(frm, cdt, cdn) {
    // var totEXP = 0
    // var CloseBal1 = 0
    // var d = locals[cdt][cdn];
    
    // CloseBal1 = frm.doc.closing_balance - d.expense
    // frm.doc.net_monthly_expense  += d.expense
    // frm.doc.closing_balance = CloseBal1
    // // refresh_field("")
    // frm.refresh("")
     var fundInp = 0
    var expInp = 0
    var CloseBal = 0
    $.each(frm.doc.data_aez3i,  function(i,  d) {
            fundInp += d.fund_input
            expInp += d.expense
            CloseBal = frm.doc.opening_balance + fundInp - expInp
        });
        frm.doc.closing_balance = CloseBal;
        frm.doc.net_monthly_expense  = expInp
    frm.refresh("")

}
})

// 

Check the field/label names as per your doctypes and edit them.

any other method without coding?

Nope, it just copy paste thing with minor doc.name edits.

 frappe.ui.form.on('Petty Expenses', {
opening_balance: function(frm) {
if(frm.doc.closing_balance == 0){
    frm.doc.closing_balance = frm.doc.opening_balance
  }else{
   var fundInp = 0
    var expInp = 0
    var CloseBal = 0
    $.each(frm.doc.table_qduo,  function(i,  d) {
        fundInp += d.fund_input
        expInp += d.expense
        CloseBal = frm.doc.opening_balance + fundInp - expInp
    });
    frm.doc.closing_balance = CloseBal;

 }

refresh_field("closing_balance")
},


before_save: function(frm) {
var fundInp = 0
var expInp = 0
var CloseBal = 0
    $.each(frm.doc.table_qduo,  function(i,  d) {
        fundInp += d.fund_input
        expInp += d.expense
        CloseBal = frm.doc.opening_balance + fundInp - expInp
    });
    frm.doc.closing_balance = CloseBal;
    frm.doc.net_monthly_expense  = expInp
    frm.refresh("")
    }
 })



frappe.ui.form.on('Cash Book Child', {
fund_input: function(frm, cdt, cdn) {
// var d = locals[cdt][cdn];
// var fundInp = 0
// var CloseBal = 0
// frm.doc.closing_balance += d.fund_input

// refresh_field("closing_balance")

 var fundInp = 0
var expInp = 0
var CloseBal = 0
$.each(frm.doc.table_qduo,  function(i,  d) {
        fundInp += d.fund_input
        expInp += d.expense
        CloseBal = frm.doc.opening_balance + fundInp - expInp
        });
    frm.doc.closing_balance = CloseBal;
    frm.doc.net_monthly_expense  = expInp
frm.refresh("")

},

expense: function(frm, cdt, cdn) {
// var totEXP = 0
// var CloseBal1 = 0
// var d = locals[cdt][cdn];

// CloseBal1 = frm.doc.closing_balance - d.expense
// frm.doc.net_monthly_expense  += d.expense
// frm.doc.closing_balance = CloseBal1
// // refresh_field("")
// frm.refresh("")
 var fundInp = 0
var expInp = 0
var CloseBal = 0
$.each(frm.doc.table_qduo,  function(i,  d) {
        fundInp += d.fund_input
        expInp += d.expense
        CloseBal = frm.doc.opening_balance + fundInp - expInp
    });
    frm.doc.closing_balance = CloseBal;
    frm.doc.net_monthly_expense  = expInp
frm.refresh("")

}
})

//
1 Like

This is working for me. Thanks

1 Like